Class: FunTranslations::Translation

Inherits:
Object
  • Object
show all
Defined in:
lib/fun_translations/translation.rb

Overview

This class represents a response returned by FunTranslation API

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#audioObject (readonly)

Returns the value of attribute audio.



6
7
8
# File 'lib/fun_translations/translation.rb', line 6

def audio
  @audio
end

#original_textObject (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

#speedObject (readonly)

Returns the value of attribute speed.



6
7
8
# File 'lib/fun_translations/translation.rb', line 6

def speed
  @speed
end

#toneObject (readonly)

Returns the value of attribute tone.



6
7
8
# File 'lib/fun_translations/translation.rb', line 6

def tone
  @tone
end

#translated_textObject (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

#translationObject (readonly)

Returns the value of attribute translation.



6
7
8
# File 'lib/fun_translations/translation.rb', line 6

def translation
  @translation
end