Class: EacRubyUtils::Fs::ClearableDirectory
- Defined in:
- lib/eac_ruby_utils/fs/clearable_directory.rb
Constant Summary collapse
- CLEARABLE_BASENAME =
'.clearable_directory'
Instance Method Summary collapse
- #clear ⇒ Object
- #clearable? ⇒ Boolean
- #clearable_negate_message ⇒ Object
- #clearable_note_file ⇒ Object
- #validate_clearable ⇒ Object
Methods inherited from Pathname
Instance Method Details
#clear ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/eac_ruby_utils/fs/clearable_directory.rb', line 11 def clear validate_clearable directory? ? clear_directory : clear_no_directory mkpath ::FileUtils.touch(clearable_note_file.to_path) self end |
#clearable? ⇒ Boolean
19 20 21 |
# File 'lib/eac_ruby_utils/fs/clearable_directory.rb', line 19 def clearable? ? true : false end |
#clearable_negate_message ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/eac_ruby_utils/fs/clearable_directory.rb', line 23 def return if !exist? || empty? return "Path \"#{self}\" exists, is not empty and is not a directory" unless directory? return if clearable_note_file.exist? "Directory \"#{self}\" is not empty and does not have a #{CLEARABLE_BASENAME} file" end |
#clearable_note_file ⇒ Object
31 32 33 |
# File 'lib/eac_ruby_utils/fs/clearable_directory.rb', line 31 def clearable_note_file join(CLEARABLE_BASENAME) end |
#validate_clearable ⇒ Object
35 36 37 38 |
# File 'lib/eac_ruby_utils/fs/clearable_directory.rb', line 35 def validate_clearable = raise if end |