lib/fun_translations/translation.rb in fun_translations-0.0.1.rc1 vs lib/fun_translations/translation.rb in fun_translations-0.0.1

- old
+ new

@@ -5,13 +5,15 @@ class Translation attr_reader :translated_text, :original_text, :translation, :audio, :speed, :tone # Initializes a new Translation object def initialize(raw_translation) - if raw_translation['translated'].respond_to?(:key?) && raw_translation['translated'].key?('audio') - @audio = raw_translation['translated']['audio'] + translated = raw_translation['translated'] + + if translated.respond_to?(:key?) && translated.key?('audio') + @audio = translated['audio'] else - @translated_text = raw_translation['translated'] + @translated_text = translated end @original_text = raw_translation['text'] @translation = raw_translation['translation'] @speed = raw_translation['speed']