G
Grant Curell
Like a lot of people I'm new to Ruby and I'm trying to do something I
thought would be pretty simple. I want the user to give me input in the
form of a filename and then subsequently open the file. Here is what I
have so far:
class FileHandler
def initialize()
@fileToParse = fileToParse #I get user input in the form of gets in
#another class.
if File.new(fileToParse)
puts 'File successfully opened.'
else
puts 'File failed to open.'
Kernel.exit
end
end
end
However, that won't work. Doing something like
File.new("C:/Users/grant/Desktop/test.txt") works just fine though. The
way I'm currently doing it throws the following error:
F:/Programming/eclipseWorkspace/CSE_655/file_handler.rb:8:in
`initialize': Invalid argument - C:/Users/grant/Desktop/test.txt
(Errno::EINVAL)
thought would be pretty simple. I want the user to give me input in the
form of a filename and then subsequently open the file. Here is what I
have so far:
class FileHandler
def initialize()
@fileToParse = fileToParse #I get user input in the form of gets in
#another class.
if File.new(fileToParse)
puts 'File successfully opened.'
else
puts 'File failed to open.'
Kernel.exit
end
end
end
However, that won't work. Doing something like
File.new("C:/Users/grant/Desktop/test.txt") works just fine though. The
way I'm currently doing it throws the following error:
F:/Programming/eclipseWorkspace/CSE_655/file_handler.rb:8:in
`initialize': Invalid argument - C:/Users/grant/Desktop/test.txt
(Errno::EINVAL)