Module: FunWith::Files::FileRequirements

Defined in:
lib/fun_with/files/file_requirements.rb

Instance Method Summary collapse

Instance Method Details

#_raise_error_if_not(test, msg, error_class) ⇒ Object



4
5
6
7
8
# File 'lib/fun_with/files/file_requirements.rb', line 4

def _raise_error_if_not test, msg, error_class
  if test
    raise error_class.new( msg + "(file: #{self})" )
  end
end

#needs_to_be_a_file(error_msg = "Path is not a file") ⇒ Object



10
11
12
# File 'lib/fun_with/files/file_requirements.rb', line 10

def needs_to_be_a_file error_msg = "Path is not a file"
  _raise_error_if_not self.file?, error_msg, Errno::ENOENT
end

#needs_to_be_empty(error_msg = "Path needs to point to") ⇒ Object



18
19
20
# File 'lib/fun_with/files/file_requirements.rb', line 18

def needs_to_be_empty error_msg = "Path needs to point to"
  _raise_error_if_not self.empty?, error_msg, Errno::ENOENT
end

#needs_to_be_writable(error_msg = "Path is not writable") ⇒ Object



14
15
16
# File 'lib/fun_with/files/file_requirements.rb', line 14

def needs_to_be_writable error_msg = "Path is not writable"
  _raise_error_if_not self.writable?, error_msg, Errno::ENOENT
end