Class: ResultParser
- Inherits:
-
Object
- Object
- ResultParser
- Defined in:
- lib/google_translate/result_parser.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(result) ⇒ ResultParser
constructor
A new instance of ResultParser.
- #nouns ⇒ Object
- #synonym_exclamations ⇒ Object
- #synonym_nouns ⇒ Object
- #synonym_verbs ⇒ Object
- #translation ⇒ Object
- #translit ⇒ Object
- #verbs ⇒ Object
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
#result ⇒ Object (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
#nouns ⇒ Object
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_exclamations ⇒ Object
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_nouns ⇒ Object
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_verbs ⇒ Object
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 |
#translation ⇒ Object
9 10 11 |
# File 'lib/google_translate/result_parser.rb', line 9 def translation result[0][0][0] end |
#translit ⇒ Object
13 14 15 |
# File 'lib/google_translate/result_parser.rb', line 13 def translit result[0][1][2] end |
#verbs ⇒ Object
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 |