Class: Shellissimo::CommandsCollection
- Inherits:
-
Object
- Object
- Shellissimo::CommandsCollection
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/shellissimo/commands_collection.rb
Instance Method Summary collapse
- #<<(command) ⇒ Object
- #each(&block) ⇒ Object
- #find_by_name_or_alias(name_or_alias) ⇒ Object (also: #[])
-
#initialize ⇒ CommandsCollection
constructor
A new instance of CommandsCollection.
- #push(*commands) ⇒ Object
Constructor Details
#initialize ⇒ CommandsCollection
Returns a new instance of CommandsCollection.
11 12 13 |
# File 'lib/shellissimo/commands_collection.rb', line 11 def initialize @commands = [] end |
Instance Method Details
#<<(command) ⇒ Object
25 26 27 28 |
# File 'lib/shellissimo/commands_collection.rb', line 25 def <<(command) @commands << command self end |
#each(&block) ⇒ Object
21 22 23 |
# File 'lib/shellissimo/commands_collection.rb', line 21 def each(&block) @commands.each(&block) end |
#find_by_name_or_alias(name_or_alias) ⇒ Object Also known as: []
15 16 17 18 |
# File 'lib/shellissimo/commands_collection.rb', line 15 def find_by_name_or_alias(name_or_alias) @commands.detect { |c| c.name == name_or_alias } or raise CommandNotFoundError, "Command #{name_or_alias} not found" end |
#push(*commands) ⇒ Object
30 31 32 33 |
# File 'lib/shellissimo/commands_collection.rb', line 30 def push(*commands) @commands.push(*commands) self end |