From: Tanner Burson Date: 2006-07-20T04:01:24+09:00 Subject: Re: maybe I don't understand the .to_a method... ------=_Part_88641_12913295.1153335677232 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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) -- ===Tanner Burson=== tanner.burson@gmail.com http://tannerburson.com <---Might even work one day... ------=_Part_88641_12913295.1153335677232--