Class: YoudaoFanyi::Result
- Inherits:
-
Object
- Object
- YoudaoFanyi::Result
- Defined in:
- lib/youdao-fanyi/result.rb
Instance Attribute Summary collapse
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#explains ⇒ Object
readonly
Returns the value of attribute explains.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#translation ⇒ Object
readonly
Returns the value of attribute translation.
-
#web_explains ⇒ Object
readonly
Returns the value of attribute web_explains.
Instance Method Summary collapse
-
#initialize(xml_data) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(xml_data) ⇒ Result
Returns a new instance of Result.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/youdao-fanyi/result.rb', line 7 def initialize(xml_data) data = parse(xml_data)["youdao_fanyi"] return if data.nil? @error_code = data["errorCode"] @query = data["query"] @translation = data["translation"]["paragraph"] unless data["translation"].nil? unless data.nil? unless data["basic"].nil? unless data["basic"]["explains"].nil? @explains = data["basic"]["explains"]["ex"] end end end @web_explains = data["web"]["explain"] unless data["web"].nil? end |
Instance Attribute Details
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
5 6 7 |
# File 'lib/youdao-fanyi/result.rb', line 5 def error_code @error_code end |
#explains ⇒ Object (readonly)
Returns the value of attribute explains.
5 6 7 |
# File 'lib/youdao-fanyi/result.rb', line 5 def explains @explains end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
5 6 7 |
# File 'lib/youdao-fanyi/result.rb', line 5 def query @query end |
#translation ⇒ Object (readonly)
Returns the value of attribute translation.
5 6 7 |
# File 'lib/youdao-fanyi/result.rb', line 5 def translation @translation end |
#web_explains ⇒ Object (readonly)
Returns the value of attribute web_explains.
5 6 7 |
# File 'lib/youdao-fanyi/result.rb', line 5 def web_explains @web_explains end |