Class: TyranoDsl::ExportGame::FileActions::ClearDirectory
- Inherits:
-
Object
- Object
- TyranoDsl::ExportGame::FileActions::ClearDirectory
- 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
- #path ⇒ String readonly
Instance Method Summary collapse
-
#initialize(path) ⇒ ClearDirectory
constructor
A new instance of ClearDirectory.
- #run(tyrano_project_path) ⇒ void
- #to_s ⇒ Object
Constructor Details
#initialize(path) ⇒ ClearDirectory
Returns a new instance of ClearDirectory.
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
#path ⇒ String (readonly)
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.
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_s ⇒ Object
31 32 33 |
# File 'lib/tyrano_dsl/export_game/file_actions/clear_directory.rb', line 31 def to_s "Clear directory [#{path}]" end |