From: John Fink Date: 2006-07-20T04:04:41+09:00 Subject: Re: maybe I don't understand the .to_a method... ------=_Part_70492_22317583.1153335877924 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/19/06, Tanner Burson wrote: > > On 7/19/06, John Fink wrote: > > > > > > > > require 'net/http' > > > > require 'uri' > > > > > > > > filename = 'test.txt' > > > > > > > > def testget(filename) > > > > url = URI.parse('http://vineland.lib.muohio.edu/' + filename ) > > > > req = Net::HTTP::Get.new(url.path) > > > > res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) > } > > > > end > > > > > > > > test = testget(filename) > > > > test2 = test.to_a > > > > > > test2 = test.split(/[\n\r]+/) > > > > > > > puts test > > > > puts test2[0] > > > > puts test2[1] > > > > > > that would "eat" blank lines though, but gets you closer... > > > > > > > > > > > > > Aha, split. I've now tried split on arbitrary lines in irb, and it > works > > on > > them. But trying split in my little program here yields the following > > error: > > > > testget.rb:13: private method `split' called for # > readbody=true> (NoMethodError) > > > > Googling this hairy error gives me no leads. > > > > jf > > > > Try doing test2 = test.body.split (given the sample code you listed > above) That did it!!! Thanks much, Phillip and Tanner. jf ------=_Part_70492_22317583.1153335877924--