Class: Beats::Command::Help::CommandGroup
- Inherits:
-
Object
- Object
- Beats::Command::Help::CommandGroup
- Defined in:
- lib/beats/commands/help.rb
Instance Method Summary collapse
- #command(command, description) ⇒ Object
- #display(&block) ⇒ Object
-
#initialize(&block) ⇒ CommandGroup
constructor
A new instance of CommandGroup.
Constructor Details
#initialize(&block) ⇒ CommandGroup
Returns a new instance of CommandGroup.
34 35 36 37 |
# File 'lib/beats/commands/help.rb', line 34 def initialize(&block) @commands = [] instance_eval(&block) end |
Instance Method Details
#command(command, description) ⇒ Object
38 39 40 |
# File 'lib/beats/commands/help.rb', line 38 def command(command, description) @commands << [command, description] end |
#display(&block) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/beats/commands/help.rb', line 41 def display(&block) max_length = @commands.map {|c| c.first.size }.sort.last @commands.each do |c| command, description = c.first, c.last yield(" #{command.ljust(max_length+2)}# #{description}") end end |