There must be another way to do this, but this works for me.
I should use a gem. :)
- Let's make a function with this. [DONE] I don't know how to cross text on markdown.
- Let's make a class <-- A nice wrapper.
There must be another way to do this, but this works for me.
I should use a gem. :)
def download_file(uri, file_name) | |
require 'net/http' | |
#Net::HTTP.get('http://code.jquery.com', "/jquery-1.7.1.js") | |
uri = URI(uri) | |
dwn_file = Net::HTTP.get(uri) # => String | |
file = File.new(file_name, "w") | |
file.write(dwn_file) | |
file.close | |
end | |
download_file('http://code.jquery.com/jquery-1.7.1.js', 'jquery.js') |