Class: Zendesk::Main::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/zendesk/main.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(curl) ⇒ Response

Returns a new instance of Response.



82
83
84
85
86
87
88
89
# File 'lib/zendesk/main.rb', line 82

def initialize(curl)
  @curl = curl
  @url = curl.url
  @status = curl.response_code
  @body = curl.body_str
  @headers_raw = curl.header_str
  parse_headers
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



80
81
82
# File 'lib/zendesk/main.rb', line 80

def body
  @body
end

#curlObject (readonly)

Returns the value of attribute curl.



80
81
82
# File 'lib/zendesk/main.rb', line 80

def curl
  @curl
end

#headersObject (readonly)

Returns the value of attribute headers.



80
81
82
# File 'lib/zendesk/main.rb', line 80

def headers
  @headers
end

#headers_rawObject (readonly)

Returns the value of attribute headers_raw.



80
81
82
# File 'lib/zendesk/main.rb', line 80

def headers_raw
  @headers_raw
end

#statusObject (readonly)

Returns the value of attribute status.



80
81
82
# File 'lib/zendesk/main.rb', line 80

def status
  @status
end

#urlObject (readonly)

Returns the value of attribute url.



80
81
82
# File 'lib/zendesk/main.rb', line 80

def url
  @url
end

Instance Method Details

#parse_headersObject



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/zendesk/main.rb', line 91

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