Class: Pathname
Instance Method Summary collapse
-
#assert_dir!(name = nil) ⇒ self
Checks that the Pathname represents an existing directory, and returns the Pathname unmodified.
-
#assert_exist!(name = nil) ⇒ self
Checks that the Pathname represents an existing file or directory, and returns the Pathname unmodified.
-
#assert_file!(name = nil) ⇒ self
Checks that the Pathname represents an existing file, and returns the Pathname unmodified.
-
#refute_dir!(name = nil) ⇒ self
Checks that the Pathname does not represent an existing directory, and returns the Pathname unmodified.
-
#refute_exist!(name = nil) ⇒ self
Checks that the Pathname does not represent an existing file or directory, and returns the Pathname unmodified.
-
#refute_file!(name = nil) ⇒ self
Checks that the Pathname does not represent an existing file, and returns the Pathname unmodified.
Instance Method Details
#assert_dir!(name = nil) ⇒ self
Checks that the Pathname represents an existing directory, and returns the Pathname unmodified. If the Pathname fails this check, an exception is raised.
60 61 62 63 64 65 66 67 |
# File 'lib/mini_sanity/pathname.rb', line 60 def assert_dir!(name = nil) if !self.directory? raise MiniSanity::Error.new(name, "existent directory", "#{self} is not a directory") end self end |
#assert_exist!(name = nil) ⇒ self
Checks that the Pathname represents an existing file or directory, and returns the Pathname unmodified. If the Pathname fails this check, an exception is raised.
16 17 18 19 20 21 22 23 |
# File 'lib/mini_sanity/pathname.rb', line 16 def assert_exist!(name = nil) if !self.exist? raise MiniSanity::Error.new(name, "existent file or directory", "#{self} does not exist") end self end |
#assert_file!(name = nil) ⇒ self
Checks that the Pathname represents an existing file, and returns the Pathname unmodified. If the Pathname fails this check, an exception is raised.
104 105 106 107 108 109 110 111 |
# File 'lib/mini_sanity/pathname.rb', line 104 def assert_file!(name = nil) if !self.file? raise MiniSanity::Error.new(name, "existent file", "#{self} is not a file") end self end |
#refute_dir!(name = nil) ⇒ self
Checks that the Pathname does not represent an existing directory, and returns the Pathname unmodified. If the Pathname fails this check, an exception is raised.
82 83 84 85 86 87 88 89 |
# File 'lib/mini_sanity/pathname.rb', line 82 def refute_dir!(name = nil) if self.directory? raise MiniSanity::Error.new(name, "not an existent directory", "#{self} is a directory") end self end |
#refute_exist!(name = nil) ⇒ self
Checks that the Pathname does not represent an existing file or directory, and returns the Pathname unmodified. If the Pathname fails this check, an exception is raised.
38 39 40 41 42 43 44 45 |
# File 'lib/mini_sanity/pathname.rb', line 38 def refute_exist!(name = nil) if self.exist? raise MiniSanity::Error.new(name, "non-existent file or directory", "#{self} already exists") end self end |
#refute_file!(name = nil) ⇒ self
Checks that the Pathname does not represent an existing file, and returns the Pathname unmodified. If the Pathname fails this check, an exception is raised.
126 127 128 129 130 131 132 133 |
# File 'lib/mini_sanity/pathname.rb', line 126 def refute_file!(name = nil) if self.file? raise MiniSanity::Error.new(name, "not an existent file", "#{self} is a file") end self end |