class Translator
translator.rb¶ ↑
- Author
-
Gary Márquez
-
garyjscs@gmail.com
- Description
-
Translates string of 'Hello world'
Public Class Methods
new(language)
click to toggle source
-
Initialize the object and set language for translation
-
If language is not set returns the spanish version of string
# File lib/hola_gary/translator.rb, line 13 def initialize(language) @language = language end
Public Instance Methods
hi()
click to toggle source
-
Returns classic 'Hello world' string in selected language
-
If language is not set returns the spanish version of string
# File lib/hola_gary/translator.rb, line 19 def hi case @language when "english" "Hello world!" else "¡Hola mundo!" end end