Class: FileCreator
- Inherits:
-
Object
- Object
- FileCreator
- Defined in:
- lib/file_creator.rb
Overview
Responsible for creating a file and creating error messages which we can present back to the user if it failed
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
4 5 6 |
# File 'lib/file_creator.rb', line 4 def error @error end |
Instance Method Details
#create(file_name) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/file_creator.rb', line 5 def create(file_name) File.new(file_name, 'w') rescue Errno::EACCES raise Error, "You do not have permission to write to that location (#{file_name})" rescue Errno::EISDIR raise Error, "File name is a directory (#{file_name})" rescue Errno::ENOTDIR raise Error, "File name refers to a directory which does not exist (#{file_name})" end |