Reputation: 16502
Ruby
req = Net::HTTP.get_response(URI.parse('http://www.domain.com/coupons.txt'))
@play = req.body
req.body give me the entire page in to a string. What if I just want to read line by line? gets? Can you read line by line through a http get? Or do I just need to read a file from local?
The text file looks like this
1 John Ham 25,000
2 Ham John 25,000
3 Ohail Spam 25,000
4 Ted Dome 25,000
5 Di Di 25,000
Upvotes: 1
Views: 2687
Reputation: 3351
If you don't want to read the entire body, try using the Net::HTTPResponse#read_body
method:
The body is provided in fragments, as it is read in from the socket.
Upvotes: 1
Reputation: 6840
Since the body method returns a string, I would have to assume you can use the String#each_line
method. Check out the documentation for String#each_line.
Upvotes: 1