Class: EhbrsRubyUtils::WebUtils::Videos::File
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- EhbrsRubyUtils::WebUtils::Videos::File
- Defined in:
- lib/ehbrs_ruby_utils/web_utils/videos/file.rb
Instance Method Summary collapse
- #can_rename? ⇒ Boolean
- #exist? ⇒ Boolean
-
#initialize(data) ⇒ File
constructor
A new instance of File.
- #path_changed? ⇒ Boolean
- #remove ⇒ Object
- #rename ⇒ Object
Constructor Details
#initialize(data) ⇒ File
Returns a new instance of File.
9 10 11 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file.rb', line 9 def initialize(data) super(::OpenStruct.new(data)) end |
Instance Method Details
#can_rename? ⇒ Boolean
21 22 23 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file.rb', line 21 def can_rename? ::File.exist?(original_path) && !::File.exist?(new_path) end |
#exist? ⇒ Boolean
13 14 15 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file.rb', line 13 def exist? ::File.exist?(original_path) end |
#path_changed? ⇒ Boolean
17 18 19 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file.rb', line 17 def path_changed? original_path != new_path end |
#remove ⇒ Object
25 26 27 28 29 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file.rb', line 25 def remove return unless exist? ::File.unlink(original_path) end |
#rename ⇒ Object
31 32 33 34 35 36 |
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file.rb', line 31 def rename return unless can_rename? ::FileUtils.mkdir_p(::File.dirname(new_path)) ::FileUtils.mv(original_path, new_path) end |