Class: Translator
- Inherits:
-
Object
- Object
- Translator
- Defined in:
- lib/hola_gary/translator.rb
Overview
translator.rb
- Author
-
Gary Márquez
- Description
-
Translates string of ‘Hello world’
Instance Method Summary collapse
-
#hi ⇒ Object
-
Returns classic ‘Hello world’ string in selected language - If language is not set returns the spanish version of string.
-
-
#initialize(language) ⇒ Translator
constructor
-
Initialize the object and set language for translation - If language is not set returns the spanish version of string.
-
Constructor Details
#initialize(language) ⇒ Translator
-
Initialize the object and set language for translation
-
If language is not set returns the spanish version of string
13 14 15 |
# File 'lib/hola_gary/translator.rb', line 13 def initialize(language) @language = language end |
Instance Method Details
#hi ⇒ Object
-
Returns classic ‘Hello world’ string in selected language
-
If language is not set returns the spanish version of string
19 20 21 22 23 24 25 26 |
# File 'lib/hola_gary/translator.rb', line 19 def hi case @language when "english" "Hello world!" else "¡Hola mundo!" end end |