Class: TyranoDsl::ExportGame::FileActions::FileCopy

Inherits:
Object
  • Object
show all
Includes:
FileActionsModule
Defined in:
lib/tyrano_dsl/export_game/file_actions/file_copy.rb

Overview

Direct copy of a file from a source to a destination

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from_path, to_path) ⇒ FileCopy

Returns a new instance of FileCopy.

Parameters:

  • from_path (String)
  • to_path (String)


18
19
20
21
22
# File 'lib/tyrano_dsl/export_game/file_actions/file_copy.rb', line 18

def initialize(from_path, to_path)
  @from_path = from_path
  @to_path = to_path
  log {self.to_s}
end

Instance Attribute Details

#from_pathString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/tyrano_dsl/export_game/file_actions/file_copy.rb', line 12

def from_path
  @from_path
end

#to_pathString (readonly)

Returns:

  • (String)


14
15
16
# File 'lib/tyrano_dsl/export_game/file_actions/file_copy.rb', line 14

def to_path
  @to_path
end

Instance Method Details

#run(tyrano_project_path) ⇒ void

This method returns an undefined value.

Parameters:

  • tyrano_project_path (String)


26
27
28
29
30
31
# File 'lib/tyrano_dsl/export_game/file_actions/file_copy.rb', line 26

def run(tyrano_project_path)
  full_path = File.join(tyrano_project_path, to_path)
  log {"Copying file [#{from_path}] to [#{full_path}]"}
  create_parent_dir_if_not_exist(full_path)
  FileUtils.copy_file from_path, full_path
end

#to_sObject



33
34
35
# File 'lib/tyrano_dsl/export_game/file_actions/file_copy.rb', line 33

def to_s
  "Copy file [#{from_path}] to [#{to_path}]"
end