Class: Maestro::Command

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

.argumentsObject (readonly)

Returns the value of attribute arguments.



11
12
13
# File 'lib/commands/command.rb', line 11

def arguments
  @arguments
end

.descriptionObject (readonly)

Returns the value of attribute description.



10
11
12
# File 'lib/commands/command.rb', line 10

def description
  @description
end

.nameObject (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

.describeObject



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

#invokeObject

Raises:



29
30
31
# File 'lib/commands/command.rb', line 29

def invoke
  raise RuntimeError.new("#{self.class} has no invocation!")
end