class TranslatorSrt::GoogleTranslate::ResultParser
Public Class Methods
new(result)
click to toggle source
# File lib/translator_srt/google_translate/result_parser.rb, line 4 def initialize(result) @result = result end
Public Instance Methods
to_s()
click to toggle source
# File lib/translator_srt/google_translate/result_parser.rb, line 8 def to_s normalize_translation @result.join end
Private Instance Methods
normalize_translation()
click to toggle source
# File lib/translator_srt/google_translate/result_parser.rb, line 16 def normalize_translation to_one_ar list_keys = { "-->" => ["###"], "," => [" ## ", "##"], ":" => [" # ", "#"], } list_keys.each do |key_group, group| group.each do |key| @result.each_index do |index_translation| @result[index_translation] = @result[index_translation].gsub key, key_group end end end end
permit_translation()
click to toggle source
# File lib/translator_srt/google_translate/result_parser.rb, line 46 def permit_translation @result = @result.first end
to_one_ar()
click to toggle source
# File lib/translator_srt/google_translate/result_parser.rb, line 35 def to_one_ar permit_translation result_in_one_array = [] @result.each do |item| result_in_one_array.append item.first end @result = result_in_one_array end