S
Samuel Sternhagen
I have used Net::HTTP like this:
Net::HTTP.get 'google.com', '/index.html'
I would like to pass it a variable instead.
I tried this:
irb(main):001:0> require 'net/http'
=> true
irb(main):002:0> url = String.new
=> ""
irb(main):003:0> url = "'google.com', '/index.html'"
=> "'google.com', '/index.html'"
irb(main):004:0> Net::HTTP.get_print(url)
NoMethodError: undefined method `host' for "'google.com',
'/index.html'":String
from /usr/lib/ruby/1.8/net/http.rb:379:in `get_response'
from /usr/lib/ruby/1.8/net/http.rb:337:in `get_print'
from (irb):4
from :0
How do I pass a variable to Net:HTTP ?
Net::HTTP.get 'google.com', '/index.html'
I would like to pass it a variable instead.
I tried this:
irb(main):001:0> require 'net/http'
=> true
irb(main):002:0> url = String.new
=> ""
irb(main):003:0> url = "'google.com', '/index.html'"
=> "'google.com', '/index.html'"
irb(main):004:0> Net::HTTP.get_print(url)
NoMethodError: undefined method `host' for "'google.com',
'/index.html'":String
from /usr/lib/ruby/1.8/net/http.rb:379:in `get_response'
from /usr/lib/ruby/1.8/net/http.rb:337:in `get_print'
from (irb):4
from :0
How do I pass a variable to Net:HTTP ?