PLEASE NOTE THAT I AM A NOOB
So I recently started learning Ruby and a buddy is motivating me to get into it so he helped me get on my way. We're currently building a program that allows you to download the HTML code from a page. My code isn't working. The code is:
require 'net/http'
print "Source: "
source = gets.chomp
print "Path: "
filename = gets.chomp
page = Net::HTTP.get(source, path)
path = File.join(File.dirname(__FILE__), filename)
file = File.open(path, 'r+')
file.write(page)
file.close()
and the error message I get is
webdownload.rb:11:in `initialize': Is a directory - ./ (Errno::EISDIR)
from webdownload.rb:11:in `open'
from webdownload.rb:11:in `<main>'
My buddy said it's because I'm declaring a directory name instead of a file name (which I can deduce from the error message). I however don't know how to change it into a file name.
Aucun commentaire:
Enregistrer un commentaire