I am trying to learn some ruby http request response code from this tutorial -
http://danknox.github.io/2013/01/27/using-rubys-native-nethttp-library/
Code so far -
require "net/http"
require "uri"
uri = URI.parse("http://api.random.com")
http = Net::HTTP.new(uri.host, uri.port)
# Continuing our example from above
request = Net::HTTP::Get.new("/search?question=somequestion")
response = http.request(request)
response.code
=>"200"
response.body
=> # Raw response body would go here needing to be parsed
error -
Test.rb:13: syntax error, unexpected tASSOC, expecting $end
=> "200"
^
I don't know why this happens. I removed the space and the error remains. I saw 3-4 Stack overflow posts on this, but they did not help.