Class: Aliyun::ESS::Base::Response

Inherits:
String
  • Object
show all
Defined in:
lib/aliyun/ess/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from String

#camelize, #remove_extended, #remove_extended!, #underscore, #valid_utf8?

Constructor Details

#initialize(response) ⇒ Response



8
9
10
11
12
# File 'lib/aliyun/ess/response.rb', line 8

def initialize(response)
  @response = response
  @body     = response.body.to_s
  super(body)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



7
8
9
# File 'lib/aliyun/ess/response.rb', line 7

def body
  @body
end

#parsedObject (readonly)

Returns the value of attribute parsed.



7
8
9
# File 'lib/aliyun/ess/response.rb', line 7

def parsed
  @parsed
end

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/aliyun/ess/response.rb', line 7

def response
  @response
end

Instance Method Details

#[](header) ⇒ Object



24
25
26
# File 'lib/aliyun/ess/response.rb', line 24

def [](header)
  headers[header]
end

#codeObject



32
33
34
# File 'lib/aliyun/ess/response.rb', line 32

def code
  response.code.to_i
end

#each(&block) ⇒ Object



28
29
30
# File 'lib/aliyun/ess/response.rb', line 28

def each(&block)
  headers.each(&block)
end

#errorObject



50
51
52
# File 'lib/aliyun/ess/response.rb', line 50

def error
  @error ||= Error.new(parsed, self)
end

#error?Boolean



46
47
48
# File 'lib/aliyun/ess/response.rb', line 46

def error?
  !success? && !parsed.code.nil?
end

#headersObject



14
15
16
17
18
19
20
21
22
# File 'lib/aliyun/ess/response.rb', line 14

def headers
  @headers ||= begin
    headers = {}
    response.each do |header, value|
      headers[header] = value
    end
    headers
  end
end

#inspectObject



59
60
61
# File 'lib/aliyun/ess/response.rb', line 59

def inspect
  "#<%s:0x%s %s %s>" % [self.class, object_id, response.code, response.message]
end