Class: Flo::CommandCollection
- Inherits:
-
Object
- Object
- Flo::CommandCollection
- Extended by:
- Forwardable
- Defined in:
- lib/flo/command_collection.rb
Overview
A collection of commands. Behaves like a Hash, except that fetching a key that does not exist raises an error
Instance Method Summary collapse
-
#[](key) ⇒ Object
Returns the value corresponding to the key.
-
#initialize ⇒ CommandCollection
constructor
A new instance of CommandCollection.
Constructor Details
#initialize ⇒ CommandCollection
Returns a new instance of CommandCollection.
19 20 21 |
# File 'lib/flo/command_collection.rb', line 19 def initialize @commands = {} end |
Instance Method Details
#[](key) ⇒ Object
Returns the value corresponding to the key. Identical to accessing Hash values, except that fetching a value that does not exist raises an error
28 29 30 31 |
# File 'lib/flo/command_collection.rb', line 28 def [](key) raise CommandNotDefinedError.new("#{key} command is not defined") unless @commands.has_key?(key) @commands[key] end |