Class: Flo::CommandCollection

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeCommandCollection

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

Parameters:

  • key (String)

    Name of the command

Raises:



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