Class: Fission::Command
- Extended by:
- Forwardable
- Includes:
- CommandHelpers
- Defined in:
- lib/fission/command.rb,
lib/fission/command/info.rb,
lib/fission/command/stop.rb,
lib/fission/command/clone.rb,
lib/fission/command/start.rb,
lib/fission/command/delete.rb,
lib/fission/command/status.rb,
lib/fission/command/suspend.rb,
lib/fission/command/snapshot_list.rb,
lib/fission/command/snapshot_create.rb,
lib/fission/command/snapshot_delete.rb,
lib/fission/command/snapshot_revert.rb
Direct Known Subclasses
Clone, Delete, Info, SnapshotCreate, SnapshotDelete, SnapshotList, SnapshotRevert, Start, Status, Stop, Suspend
Defined Under Namespace
Classes: Clone, Delete, Info, SnapshotCreate, SnapshotDelete, SnapshotList, SnapshotRevert, Start, Status, Stop, Suspend
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Internal: Returns the Array arguments of the command.
-
#options ⇒ Object
readonly
Internal: Returns the OpenStruct options of the command.
Class Method Summary collapse
-
.help ⇒ Object
Internal: Helper method to return the help text of a command.
Instance Method Summary collapse
-
#command_name(klass = self) ⇒ Object
Internal: Helper method to determine the command name of command class.
-
#execute ⇒ Object
Internal: Primary method for performing an action within a command.
-
#initialize(args = []) ⇒ Command
constructor
Internal: Initializes a new Command with some basic setup.
-
#summary ⇒ Object
Internal: Summmary of the command.
-
#ui ⇒ Object
Internal: Helper method used to delegate UI related methods through.
Methods included from CommandHelpers
#incorrect_arguments, #parse_arguments
Constructor Details
#initialize(args = []) ⇒ Command
27 28 29 30 31 |
# File 'lib/fission/command.rb', line 27 def initialize(args=[]) ui @options = OpenStruct.new @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Internal: Returns the Array arguments of the command.
15 16 17 |
# File 'lib/fission/command.rb', line 15 def args @args end |
#options ⇒ Object (readonly)
Internal: Returns the OpenStruct options of the command.
12 13 14 |
# File 'lib/fission/command.rb', line 12 def @options end |
Class Method Details
.help ⇒ Object
Internal: Helper method to return the help text of a command. This is intended to be used by a command class which inherits from this class. This method will call the ‘option_parser’ method which must be defined in any class which inherits from this class.
Examples
Fission::Command::Suspend.help
Returns a String of the output parser text.
91 92 93 |
# File 'lib/fission/command.rb', line 91 def self.help self.new.option_parser.to_s end |
Instance Method Details
#command_name(klass = self) ⇒ Object
Internal: Helper method to determine the command name of command class. This should only be called against descendants of this class.
#xamples:
Fission::Command::SnapshotList.new.command_name
# => 'snapshot list'
Returns the command name as a String.
63 64 65 66 67 |
# File 'lib/fission/command.rb', line 63 def command_name(klass=self) klass.class.name.split('::')[2]. gsub(/([a-z\d])([A-Z])/,'\1_\2'). gsub('_', ' ').downcase end |
#execute ⇒ Object
Internal: Primary method for performing an action within a command.
Examples
command.execute
Returns nothing
40 41 42 |
# File 'lib/fission/command.rb', line 40 def execute parse_arguments end |
#summary ⇒ Object
Internal: Summmary of the command. This is to be implemented by any class which inherits from this class.
Examples
command.summary
# => 'This command does x and y'
Returns a String summary of the command.
77 78 79 |
# File 'lib/fission/command.rb', line 77 def summary raise NotImplementedError end |