Class: FunTranslations::Translation
- Inherits:
-
Object
- Object
- FunTranslations::Translation
- Defined in:
- lib/fun_translations/translation.rb
Overview
This class represents a response returned by FunTranslation API
Instance Attribute Summary collapse
-
#audio ⇒ Object
readonly
Returns the value of attribute audio.
-
#original_text ⇒ Object
readonly
Returns the value of attribute original_text.
-
#speed ⇒ Object
readonly
Returns the value of attribute speed.
-
#tone ⇒ Object
readonly
Returns the value of attribute tone.
-
#translated_text ⇒ Object
readonly
Returns the value of attribute translated_text.
-
#translation ⇒ Object
readonly
Returns the value of attribute translation.
Instance Method Summary collapse
-
#initialize(raw_translation) ⇒ Translation
constructor
Initializes a new Translation object.
Constructor Details
#initialize(raw_translation) ⇒ Translation
Initializes a new Translation object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fun_translations/translation.rb', line 9 def initialize(raw_translation) translated = raw_translation['translated'] if translated.respond_to?(:key?) && translated.key?('audio') @audio = translated['audio'] else @translated_text = translated end @original_text = raw_translation['text'] @translation = raw_translation['translation'] @speed = raw_translation['speed'] @tone = raw_translation['tone'] end |
Instance Attribute Details
#audio ⇒ Object (readonly)
Returns the value of attribute audio.
6 7 8 |
# File 'lib/fun_translations/translation.rb', line 6 def audio @audio end |
#original_text ⇒ Object (readonly)
Returns the value of attribute original_text.
6 7 8 |
# File 'lib/fun_translations/translation.rb', line 6 def original_text @original_text end |
#speed ⇒ Object (readonly)
Returns the value of attribute speed.
6 7 8 |
# File 'lib/fun_translations/translation.rb', line 6 def speed @speed end |
#tone ⇒ Object (readonly)
Returns the value of attribute tone.
6 7 8 |
# File 'lib/fun_translations/translation.rb', line 6 def tone @tone end |
#translated_text ⇒ Object (readonly)
Returns the value of attribute translated_text.
6 7 8 |
# File 'lib/fun_translations/translation.rb', line 6 def translated_text @translated_text end |
#translation ⇒ Object (readonly)
Returns the value of attribute translation.
6 7 8 |
# File 'lib/fun_translations/translation.rb', line 6 def translation @translation end |