Help with IO Code

G

Ged Byrne

I'm working through "Programming Ruby - The Pragmatic
Programmer's Guide" and all has been joy and pleasure.
Now, however, I'm in difficulty.

From the IO chapter I'm running the following example:

require 'net/http'

h = Net::HTTP.new('www.pragmaticprogrammer.com', 80)
resp, data = h.get('/index.html', nil)
puts resp.message #I added this
puts data #And this
if resp.message == "OK"
#Spam assasin didn't like the Img tag in the re.
data.scan(/###/) { |x| puts x }
end


The result I'm getting is:

OK
nil
listimgs.rb:8: private method `scan' called for nil
(NoMethodError)



The code should list the images on the pragprog home
page.

Any idea whats going wrong, or how I can find out more
about whats going wrong.

I'm using 1.8.0-9


________________________________________________________________________
Want to chat instantly with your online friends? Get the FREE Yahoo!
Messenger http://uk.messenger.yahoo.com/
 
H

Hal E. Fulton

----- Original Message -----
From: "Ged Byrne" <[email protected]>
To: "ruby-talk ML" <[email protected]>
Sent: Friday, August 15, 2003 9:53 AM
Subject: Help with IO Code

I'm working through "Programming Ruby - The Pragmatic
Programmer's Guide" and all has been joy and pleasure.
Now, however, I'm in difficulty.

From the IO chapter I'm running the following example:

require 'net/http'

h = Net::HTTP.new('www.pragmaticprogrammer.com', 80)
resp, data = h.get('/index.html', nil)
puts resp.message #I added this
puts data #And this
if resp.message == "OK"
#Spam assasin didn't like the Img tag in the re.
data.scan(/###/) { |x| puts x }
end


The result I'm getting is:

OK
nil
listimgs.rb:8: private method `scan' called for nil
(NoMethodError)

That's an issue with the net/http code changing...
but I thought it had been resolved and a "compatibility"
fix had been added.

Suggest you search ruby-talk.org for messages in the
last 2-3 months about net/http -- if you can't find
the relevant ones, I'll assist.

Hal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top