Class: Greeter
- Inherits:
-
Object
- Object
- Greeter
- Defined in:
- lib/greeter.rb
Instance Attribute Summary collapse
-
#languages ⇒ Object
readonly
Returns the value of attribute languages.
Instance Method Summary collapse
- #greet_in(language, vlad, say) ⇒ Object
-
#initialize(file_path = (__dir__ + '/data/languages.json')) ⇒ Greeter
constructor
A new instance of Greeter.
Constructor Details
#initialize(file_path = (__dir__ + '/data/languages.json')) ⇒ Greeter
Returns a new instance of Greeter.
4 5 6 |
# File 'lib/greeter.rb', line 4 def initialize(file_path = (__dir__ + '/data/languages.json')) @languages = load_languages file_path end |
Instance Attribute Details
#languages ⇒ Object (readonly)
Returns the value of attribute languages.
2 3 4 |
# File 'lib/greeter.rb', line 2 def languages @languages end |
Instance Method Details
#greet_in(language, vlad, say) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/greeter.rb', line 8 def greet_in(language, vlad, say) language = language.to_s.downcase raise ArgumentError, "#{language.upcase} LANGUAGE NOT FOUND!" if @languages[language].nil? string = @languages[language.to_s.downcase].to_s.chomp string << ", vlad." if vlad puts string if say string end |