Class: Maestro::Command
- Inherits:
-
Object
- Object
- Maestro::Command
- Defined in:
- lib/commands/command.rb
Direct Known Subclasses
Find, Info, Init, List, StoryUpdater
Defined Under Namespace
Classes: Accept, ArgumentError, Cancel, Deliver, Find, Finish, Info, Init, List, Reject, RuntimeError, Start, StateUpdater, StoryUpdater, Time
Class Attribute Summary collapse
-
.arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
.description ⇒ Object
readonly
Returns the value of attribute description.
-
.name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Command
constructor
A new instance of Command.
- #invoke ⇒ Object
Constructor Details
#initialize(*args) ⇒ Command
Returns a new instance of Command.
26 27 |
# File 'lib/commands/command.rb', line 26 def initialize(*args) end |
Class Attribute Details
.arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
11 12 13 |
# File 'lib/commands/command.rb', line 11 def arguments @arguments end |
.description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/commands/command.rb', line 10 def description @description end |
.name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/commands/command.rb', line 9 def name @name end |
Class Method Details
.command(description = nil, arguments = nil) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/commands/command.rb', line 13 def command(description=nil, arguments=nil) @name = self.to_s.split("::").last.downcase.to_sym @description = description || '' @arguments = arguments || {} Maestro::Dispatcher.register self end |
.describe ⇒ Object
21 22 23 |
# File 'lib/commands/command.rb', line 21 def describe "#{name} #{arguments.collect{ |a, d| "<#{a}>"}}\n\t#{description}\n\t#{arguments.collect{ |a, desc| "<#{a}> - #{desc}" }.join(", ")}" end |
Instance Method Details
#invoke ⇒ Object
29 30 31 |
# File 'lib/commands/command.rb', line 29 def invoke raise RuntimeError.new("#{self.class} has no invocation!") end |