Class: FileTransactions::CreateDirectoryCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/file_transactions/create_directory_command.rb

Overview

This command creates a new directory. It will also create parent directories if the given path contains directories that doesn’t exist.

When this command has been executed, the created directories can be removed again by calling #undo.

Examples

# Pass in the new directory name to ::new
cmd1 = CreateDirectoryCommand.new('directory_name')

# The new directory name may be a path of multiple non exsting directories (like `mkdir -p`)
cmd2 = CreateDirectoryCommand.new('non_existing_dir1/non_existing_dir2/new_dir')

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseCommand

execute, #execute, #executed?, #failed?, #register, #undo

Constructor Details

#initialize(name) ⇒ CreateDirectoryCommand

Returns a new instance of CreateDirectoryCommand.

Parameters:

  • name (String)

    The name of the new directory. May be just a name or an absolut or relative path



23
24
25
# File 'lib/file_transactions/create_directory_command.rb', line 23

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



20
21
22
# File 'lib/file_transactions/create_directory_command.rb', line 20

def name
  @name
end