Class: Ppl::Application::CommandSuite
- Inherits:
-
Object
- Object
- Ppl::Application::CommandSuite
- Includes:
- Enumerable
- Defined in:
- lib/ppl/application/command_suite.rb
Instance Method Summary collapse
- #[](index) ⇒ Object
- #add_command(command) ⇒ Object
- #each ⇒ Object
- #find_command(name) ⇒ Object
-
#initialize ⇒ CommandSuite
constructor
A new instance of CommandSuite.
- #sort_by_name ⇒ Object
Constructor Details
#initialize ⇒ CommandSuite
Returns a new instance of CommandSuite.
7 8 9 |
# File 'lib/ppl/application/command_suite.rb', line 7 def initialize @commands = [] end |
Instance Method Details
#[](index) ⇒ Object
27 28 29 |
# File 'lib/ppl/application/command_suite.rb', line 27 def [](index) @commands[index] end |
#add_command(command) ⇒ Object
11 12 13 |
# File 'lib/ppl/application/command_suite.rb', line 11 def add_command(command) @commands.push command end |
#each ⇒ Object
15 16 17 |
# File 'lib/ppl/application/command_suite.rb', line 15 def each @commands.each { |command| yield command } end |
#find_command(name) ⇒ Object
19 20 21 |
# File 'lib/ppl/application/command_suite.rb', line 19 def find_command(name) @commands.select { |command| command.name == name }.first end |
#sort_by_name ⇒ Object
23 24 25 |
# File 'lib/ppl/application/command_suite.rb', line 23 def sort_by_name @commands.sort! { |a, b| a.name <=> b.name } end |