From: Vassilis Rizopoulos on 9 Aug 2010 03:52 On 09/08/10 09:46 , Samuel Sternhagen wrote: > Thanks for the tip Jesus. I used to program in C so I have some bad > habits. I just tried my code without creating all those objects and > everything went fine. Might I suggest reading the first few chapters of the original Pickaxe (http://ruby-doc.org/docs/ProgrammingRuby/) - lets say up to Basic I/O. Although it was written for 1.6 and is woefully out-of-date as a Ruby reference, I always found it gave one of the more digestible explanations of OO and dynamic typing. Ofcourse you can go right ahead and buy the newest version. Cheers, V.- -- http://www.ampelofilosofies.gr
From: Brian Candler on 9 Aug 2010 04:55 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/.
From: Sniper Abandon on 9 Aug 2010 07:14 Samuel Sternhagen wrote: > I have used Net::HTTP like this: Hi Sam try to use Nokogiri gem it will be easy (to unterstand) and fast also -- Posted via http://www.ruby-forum.com/.
From: tilde on 9 Aug 2010 12:21
On 08/09/10 08:45, Samuel Sternhagen wrote: > tilde wrote: >> On 08/09/10 04:18, Samuel Sternhagen wrote: >>> url = "'google.com', '/index.html'" >> >> url="google.com/index.html" >> Net::HTTP.get_print(URI.parse(url)) >> >> get and get_print expect an URI, if you don't specify both host and path >> as strings. > > Thanks :D It is working now. > This one had me stuck for hours. > No problem ^^ |