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.
8 9 10 |
# File 'lib/ppl/application/command_suite.rb', line 8 def initialize @commands = [] end |
Instance Method Details
#[](index) ⇒ Object
28 29 30 |
# File 'lib/ppl/application/command_suite.rb', line 28 def [](index) @commands[index] end |
#add_command(command) ⇒ Object
12 13 14 |
# File 'lib/ppl/application/command_suite.rb', line 12 def add_command(command) @commands.push command end |
#each ⇒ Object
16 17 18 |
# File 'lib/ppl/application/command_suite.rb', line 16 def each @commands.each { |command| yield command } end |
#find_command(name) ⇒ Object
20 21 22 |
# File 'lib/ppl/application/command_suite.rb', line 20 def find_command(name) @commands.select { |command| command.name == name }.first end |
#sort_by_name ⇒ Object
24 25 26 |
# File 'lib/ppl/application/command_suite.rb', line 24 def sort_by_name @commands.sort! { |a, b| a.name <=> b.name } end |