Class: Translator

Inherits:
Object
  • Object
show all
Defined in:
lib/greeter/translator.rb

Instance Method Summary collapse

Constructor Details

#initialize(language) ⇒ Translator

Returns a new instance of Translator.



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/greeter/translator.rb', line 2

def initialize(language)
  @language = language
  # put in yaml file
  @translations = {
    'english' => {
      hello_world: 'Hello world'
    },
    'spanish' => {
      hello_world: 'Hola mundo'
    }
  }
end

Instance Method Details

#hiObject



15
16
17
# File 'lib/greeter/translator.rb', line 15

def hi
  @translations[@language][:hello_world]
end