Class: MajortomConnector::Result
- Inherits:
-
Object
- Object
- MajortomConnector::Result
- Defined in:
- lib/majortom_connector/result.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#http_body ⇒ Object
readonly
Returns the value of attribute http_body.
-
#http_message ⇒ Object
readonly
Returns the value of attribute http_message.
-
#http_status ⇒ Object
readonly
Returns the value of attribute http_status.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #parse(response, format = "", buffer = nil) ⇒ Object
- #request_successful? ⇒ Boolean
- #response_successful? ⇒ Boolean
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
10 11 12 |
# File 'lib/majortom_connector/result.rb', line 10 def code @code end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
12 13 14 |
# File 'lib/majortom_connector/result.rb', line 12 def data @data end |
#http_body ⇒ Object (readonly)
Returns the value of attribute http_body.
8 9 10 |
# File 'lib/majortom_connector/result.rb', line 8 def http_body @http_body end |
#http_message ⇒ Object (readonly)
Returns the value of attribute http_message.
7 8 9 |
# File 'lib/majortom_connector/result.rb', line 7 def @http_message end |
#http_status ⇒ Object (readonly)
Returns the value of attribute http_status.
6 7 8 |
# File 'lib/majortom_connector/result.rb', line 6 def http_status @http_status end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
11 12 13 |
# File 'lib/majortom_connector/result.rb', line 11 def @message end |
Instance Method Details
#parse(response, format = "", buffer = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/majortom_connector/result.rb', line 22 def parse(response, format = "", buffer = nil) @http_status = response.code @http_message = response. @http_body = response.read_body return unless @http_status == "200" case format when 'xtm', 'ctm' @code = "0" @data = buffer when 'html' @code = "0" else json = MultiJson.decode(@http_body) @data = json['data'] @code = json['code'] @message = json['msg'] end end |
#request_successful? ⇒ Boolean
14 15 16 |
# File 'lib/majortom_connector/result.rb', line 14 def request_successful? @http_status == "200" end |
#response_successful? ⇒ Boolean
18 19 20 |
# File 'lib/majortom_connector/result.rb', line 18 def response_successful? @code == "0" end |