Class: Scatter::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/scatter/command.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out) ⇒ Command

Returns a new instance of Command.



3
4
5
# File 'lib/scatter/command.rb', line 3

def initialize(out)
  @out = out
end

Class Attribute Details

.abstractObject

Returns the value of attribute abstract.



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

def abstract
  @abstract
end

.command_classesObject (readonly)

Returns the value of attribute command_classes.



9
10
11
# File 'lib/scatter/command.rb', line 9

def command_classes
  @command_classes
end

.short_helpObject (readonly)

Returns the value of attribute short_help.



8
9
10
# File 'lib/scatter/command.rb', line 8

def short_help
  @short_help
end

Class Method Details

.command_nameObject



26
27
28
# File 'lib/scatter/command.rb', line 26

def command_name
  name.split('::').last.downcase
end

.helpObject



16
17
18
19
20
# File 'lib/scatter/command.rb', line 16

def help
  lines = @help.split("\n")
  indent = lines.collect { |l| l[/^(\s*)/, 1].size }.min
  lines.collect { |l| l[indent..-1] }.join("\n")
end

.inherited(sub) ⇒ Object



22
23
24
# File 'lib/scatter/command.rb', line 22

def inherited(sub)
  (@command_classes ||= []) << sub
end

.usage(short_help, long_help = nil) ⇒ Object



12
13
14
# File 'lib/scatter/command.rb', line 12

def usage(short_help, long_help = nil)
  @short_help, @help = short_help, long_help || short_help
end