Hiya. The book does things this way, so why doesn’t it work for me?
What’s going on?
def fromWeb(site, url)
# get data from website
h = Net::HTTP.new(site, 80)
resp, data=h.get(url, nil)
# process data
data.each do <- point of second error
|line|
if /DGM_navigation/ =~ line do
# decode page lineage
step=Array.new
astep, line = getNextWord(line)
while astep != nil
step.push(astep)
astep, line = getNextWord(line)
end
puts "Page Lineage"
step.each do
|astep|
step.each do
put " "
end
puts astep
end
end # end DGM_naviation
end # end data.each <- gets "undefined method 'line'", from the second
error point above
end # end def fromWeb
def getNextWord(line)
i1 = />\w+</ =~ line
string_wanted=$&[1..$&.length-1]
string_remaining=$'
return string_wanted, string_remaining
end