Class: TyranoDsl::ExportGame::FileActions::ClearDirectory

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

Overview

Remove all files from a directory

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ClearDirectory

Returns a new instance of ClearDirectory.

Parameters:

  • path (String)


15
16
17
18
# File 'lib/tyrano_dsl/export_game/file_actions/clear_directory.rb', line 15

def initialize(path)
  @path = path
  log {to_s}
end

Instance Attribute Details

#pathString (readonly)

Returns:

  • (String)


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

def path
  @path
end

Instance Method Details

#run(tyrano_project_path) ⇒ void

This method returns an undefined value.

Parameters:

  • tyrano_project_path (String)


22
23
24
25
26
27
28
29
# File 'lib/tyrano_dsl/export_game/file_actions/clear_directory.rb', line 22

def run(tyrano_project_path)
  full_path = File.join(tyrano_project_path, path)
  log {"Cleaning [#{full_path}]"}
  if File.exists? full_path
    FileUtils.remove_entry full_path
  end
  FileUtils.mkdir_p full_path
end

#to_sObject



31
32
33
# File 'lib/tyrano_dsl/export_game/file_actions/clear_directory.rb', line 31

def to_s
  "Clear directory [#{path}]"
end