Reputation: 8461
I'm doing a tutorial online and I have a challenge to read through a text file and file the one and only name that is a Palindrome. However the file containing the names is in this url http://www.codequizzes.com/challenges/names.txt
. I'm pretty new to this http request stuff. How can I require the contents of this text file with a basic ruby program?
Upvotes: 0
Views: 54
Reputation: 36880
This will copy a remote file to a local file...
require "open-uri"
remote_resource = "http://www.codequizzes.com/challenges/names.txt"
remote_data = open(remote_resource).read
local_file = open("local_names.txt", "w")
local_file.write(remote_data)
local_file.close
Upvotes: 1