Class: Scatter::Command
- Inherits:
-
Object
- Object
- Scatter::Command
- Defined in:
- lib/scatter/command.rb
Direct Known Subclasses
Scatter::Commands::Init, Scatter::Commands::List, Scatter::Commands::Push, Scatter::Commands::Receive, Scatter::Commands::Sync, SuperCommand
Class Attribute Summary collapse
-
.abstract ⇒ Object
Returns the value of attribute abstract.
-
.command_classes ⇒ Object
readonly
Returns the value of attribute command_classes.
-
.short_help ⇒ Object
readonly
Returns the value of attribute short_help.
Class Method Summary collapse
- .command_name ⇒ Object
- .help ⇒ Object
- .inherited(sub) ⇒ Object
- .usage(short_help, long_help = nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(out) ⇒ Command
constructor
A new instance of Command.
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
.abstract ⇒ Object
Returns the value of attribute abstract.
10 11 12 |
# File 'lib/scatter/command.rb', line 10 def abstract @abstract end |
.command_classes ⇒ Object (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_help ⇒ Object (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_name ⇒ Object
26 27 28 |
# File 'lib/scatter/command.rb', line 26 def command_name name.split('::').last.downcase end |
.help ⇒ Object
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 |