Module: OnlyofficeFileHelper::FileMethods
- Included in:
- FileHelper
- Defined in:
- lib/onlyoffice_file_helper/file_methods.rb
Overview
Methods used to work with files
Instance Method Summary collapse
-
#copy_file(file_path, destination) ⇒ Object
Copies a file.
-
#file_size(file_path) ⇒ Integer
Get file size in bytes.
-
#move_file(file_path, destination) ⇒ Object
Moves a file.
Instance Method Details
#copy_file(file_path, destination) ⇒ Object
Copies a file
9 10 11 12 |
# File 'lib/onlyoffice_file_helper/file_methods.rb', line 9 def copy_file(file_path, destination) FileUtils.mkdir_p(destination) unless File.directory?(destination) FileUtils.copy(file_path, destination) end |
#file_size(file_path) ⇒ Integer
Get file size in bytes
25 26 27 28 29 |
# File 'lib/onlyoffice_file_helper/file_methods.rb', line 25 def file_size(file_path) size = File.size?(file_path) size = 0 if size.nil? size end |
#move_file(file_path, destination) ⇒ Object
Moves a file
17 18 19 20 |
# File 'lib/onlyoffice_file_helper/file_methods.rb', line 17 def move_file(file_path, destination) FileUtils.mkdir_p(destination) unless File.directory?(destination) FileUtils.move(file_path, destination) end |