Module: KeyValueName::FileName::InstanceMethods
- Includes:
- Name::InstanceMethods
- Defined in:
- lib/key_value_name/mixins/file_name.rb
Overview
Instance method mixin for a file.
Instance Attribute Summary
Attributes included from Name::InstanceMethods
Instance Method Summary collapse
- #destroy! ⇒ Object
- #exist? ⇒ Boolean
-
#mkdir! ⇒ self
Ensure that the parent folder exists.
- #touch! ⇒ Object
Methods included from Name::InstanceMethods
Instance Method Details
#destroy! ⇒ Object
38 39 40 |
# File 'lib/key_value_name/mixins/file_name.rb', line 38 def destroy! FileUtils.rm_f(to_s) end |
#exist? ⇒ Boolean
13 14 15 |
# File 'lib/key_value_name/mixins/file_name.rb', line 13 def exist? File.exist?(to_s) end |
#mkdir! ⇒ self
Ensure that the parent folder exists.
22 23 24 25 |
# File 'lib/key_value_name/mixins/file_name.rb', line 22 def mkdir! parent.mkdir! self end |
#touch! ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/key_value_name/mixins/file_name.rb', line 27 def touch! retried ||= false FileUtils.touch(to_s) self rescue Errno::ENOENT FileUtils.mkdir_p(File.dirname(to_s)) raise if retried retried = true retry end |