Class: TunecoreAnnouncer::CommandDictionary

Inherits:
Object
  • Object
show all
Defined in:
lib/tunecore-announcer/command_dictionary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(yaml_filename) ⇒ CommandDictionary

Returns a new instance of CommandDictionary.



7
8
9
10
# File 'lib/tunecore-announcer/command_dictionary.rb', line 7

def initialize(yaml_filename)
  @logger = TunecoreAnnouncer::Logger.instance
  load_dictionary(yaml_filename)
end

Instance Attribute Details

#dictionaryObject (readonly)

Returns the value of attribute dictionary.



5
6
7
# File 'lib/tunecore-announcer/command_dictionary.rb', line 5

def dictionary
  @dictionary
end

Instance Method Details

#load_dictionary(yaml_filename) ⇒ Object



12
13
14
15
16
# File 'lib/tunecore-announcer/command_dictionary.rb', line 12

def load_dictionary(yaml_filename)
  @logger.info "Loading command dictionary: #{yaml_filename}"
  @dictionary = YAML.load_file(yaml_filename)
  @logger.debug @dictionary.inspect
end

#lookup(message) ⇒ Object



18
19
20
# File 'lib/tunecore-announcer/command_dictionary.rb', line 18

def lookup(message)
  @dictionary[message]
end