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

Instance Method Details

#copy_file(file_path, destination) ⇒ Object

Copies a file

Parameters:

  • file_path (String)

    path to file to be copied

  • destination (String)

    path to where to copy 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

Parameters:

  • file_path (String)

    path to file

Returns:

  • (Integer)

    size of file 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

Parameters:

  • file_path (String)

    path to file to be moved

  • destination (String)

    path to where to move 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