Class: Nineteen::Eighty::Two::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/nineteen/eighty/two/messages.rb

Constant Summary collapse

MESSAGES =
YAML.load_file File.join File.dirname(__FILE__), '..', '..', '..', '..', 'config', 'messages.yml'

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



7
8
9
10
11
# File 'lib/nineteen/eighty/two/messages.rb', line 7

def self.[] key
  key = key.to_s.upcase
  raise Exceptions::SpectrumException.new "Q - #{MESSAGES['Q']}" unless MESSAGES.has_key? key
  "#{key} - #{MESSAGES[key]}"
end

.method_missing(m, *args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/nineteen/eighty/two/messages.rb', line 17

def self.method_missing m, *args
  key = case m
  when :zero
    0
  when :one
    1
  when :two
    2
  when :three
    3
  when :four
    4
  when :five
    5
  when :six
    6
  when :seven
    7
  when :eight
    8
  when :nine
    9
  else
    m.to_s
  end
  self[key]
end

.to_hObject



13
14
15
# File 'lib/nineteen/eighty/two/messages.rb', line 13

def self.to_h
  MESSAGES
end