Class: YandexDictionary::ResponceParseService

Inherits:
Object
  • Object
show all
Defined in:
lib/yandex_dictionary/responce_parse_service.rb

Class Method Summary collapse

Class Method Details

.parse_languages(response) ⇒ Object



12
13
14
15
# File 'lib/yandex_dictionary/responce_parse_service.rb', line 12

def self.parse_languages(response)
  response.gsub!(/[\[\]]/, '')
  response.split(',')
end

.parse_translation(response) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/yandex_dictionary/responce_parse_service.rb', line 3

def self.parse_translation(response)
  json_data = JSON.parse(response)
  result = Array.new
  json_data['def'][0]['tr'].each do |translation|
    result.push(translation['text'])
  end
  return result
end