Class: EhbrsRubyUtils::WebUtils::Videos::File

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/ehbrs_ruby_utils/web_utils/videos/file.rb,
lib/ehbrs_ruby_utils/web_utils/videos/file/rename.rb

Defined Under Namespace

Classes: Rename

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ File

Returns a new instance of File.



12
13
14
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file.rb', line 12

def initialize(data)
  super(data.to_struct)
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file.rb', line 16

def exist?
  ::File.exist?(original_path)
end

#move(target_dir) ⇒ Object



20
21
22
23
24
25
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file.rb', line 20

def move(target_dir)
  ::EhbrsRubyUtils::WebUtils::Videos::File::Rename.new(
    self,
    target_dir.to_pathname.join(original_path.to_pathname.relative_path_from(root_path))
  ).perform
end

#path_changed?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file.rb', line 27

def path_changed?
  original_path != new_path
end

#removeObject



31
32
33
34
35
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file.rb', line 31

def remove
  return unless exist?

  ::File.unlink(original_path)
end

#renameObject



37
38
39
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file.rb', line 37

def rename
  ::EhbrsRubyUtils::WebUtils::Videos::File::Rename.new(self, new_path).perform
end