Class: Zendesk::Main::Response
- Inherits:
-
Object
- Object
- Zendesk::Main::Response
- Defined in:
- lib/zendesk/main.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#curl ⇒ Object
readonly
Returns the value of attribute curl.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#headers_raw ⇒ Object
readonly
Returns the value of attribute headers_raw.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(curl, format) ⇒ Response
constructor
A new instance of Response.
- #parse_headers ⇒ Object
Constructor Details
#initialize(curl, format) ⇒ Response
Returns a new instance of Response.
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/zendesk/main.rb', line 93 def initialize(curl, format) @format=format @curl = curl @url = curl.url @status = curl.response_code @body = curl.body_str @headers_raw = curl.header_str parse_headers # parse the data coming back @data = Crack::XML.parse(@body || "") if @format == "xml" end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
91 92 93 |
# File 'lib/zendesk/main.rb', line 91 def body @body end |
#curl ⇒ Object (readonly)
Returns the value of attribute curl.
91 92 93 |
# File 'lib/zendesk/main.rb', line 91 def curl @curl end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
91 92 93 |
# File 'lib/zendesk/main.rb', line 91 def data @data end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
91 92 93 |
# File 'lib/zendesk/main.rb', line 91 def headers @headers end |
#headers_raw ⇒ Object (readonly)
Returns the value of attribute headers_raw.
91 92 93 |
# File 'lib/zendesk/main.rb', line 91 def headers_raw @headers_raw end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
91 92 93 |
# File 'lib/zendesk/main.rb', line 91 def status @status end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
91 92 93 |
# File 'lib/zendesk/main.rb', line 91 def url @url end |
Instance Method Details
#parse_headers ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/zendesk/main.rb', line 105 def parse_headers hs={} return hs if headers_raw.nil? or headers_raw=="" headers_raw.split("\r\n")[1..-1].each do |h| # Rails.logger.info h m=h.match(/([^:]+):\s?(.*)/) next if m.nil? or m[2].nil? # Rails.logger.info m.inspect hs[m[1]]=m[2] end @headers=hs end |