From: Brian Candler Date: 2010-08-09T17:55:01+09:00 Subject: Re: Need help passing variable to Net::HTTP Samuel Sternhagen wrote: > 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'" Here's another option you could use: url = ['google.com', '/index.html'] Net::HTTP.get_print(*url) or more simply: host = 'google.com' path = '/index.html' Net::HTTP.get_print(host, path) -- Posted via http://www.ruby-forum.com/.