Class: ResultParser

Inherits:
Object
  • Object
show all
Defined in:
lib/google_translate/result_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ ResultParser

Returns a new instance of ResultParser.



5
6
7
# File 'lib/google_translate/result_parser.rb', line 5

def initialize result
  @result = result
end

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



3
4
5
# File 'lib/google_translate/result_parser.rb', line 3

def result
  @result
end

Instance Method Details

#nounsObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/google_translate/result_parser.rb', line 17

def nouns
  list = []

  if result[1].size > 1
    if result[1][0]
      list = result[1][0][1]
    end
  end

  list
end

#synonym_exclamationsObject



69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/google_translate/result_parser.rb', line 69

def synonym_exclamations
  list = []

  if result[11].size > 1
    if result[1][2]
      result[11][2][1].each do |r, _|
        list << r
      end
    end
  end

  list
end

#synonym_nounsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/google_translate/result_parser.rb', line 41

def synonym_nouns
  list = []

  if result[11].size > 1
    if result[1][0]
      result[11][0][1].each do |r, _|
        list << r
      end
    end
  end

  list
end

#synonym_verbsObject



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/google_translate/result_parser.rb', line 55

def synonym_verbs
  list = []

  if result[11].size > 1
    if result[1][1]
      result[11][1][1].each do |r, _|
        list << r
      end
    end
  end

  list
end

#translationObject



9
10
11
# File 'lib/google_translate/result_parser.rb', line 9

def translation
  result[0][0][0]
end

#translitObject



13
14
15
# File 'lib/google_translate/result_parser.rb', line 13

def translit
  result[0][1][2] if result[0][1]
end

#verbsObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/google_translate/result_parser.rb', line 29

def verbs
  list = []

  if result[1].size > 1
    if result[1][1]
      list = result[1][1][1]
    end
  end

  list
end