Class: Hatetepe::Response

Inherits:
Message
  • Object
show all
Defined in:
lib/hatetepe/response.rb

Instance Attribute Summary collapse

Attributes inherited from Message

#body, #connection, #headers, #http_version

Instance Method Summary collapse

Constructor Details

#initialize(status, headers = {}, body = nil, http_version = "1.1") ⇒ Response

Returns a new instance of Response.



7
8
9
10
# File 'lib/hatetepe/response.rb', line 7

def initialize(status, headers = {}, body = nil, http_version = "1.1")
  @status = status
  super headers, body, http_version
end

Instance Attribute Details

#requestObject

Returns the value of attribute request.



5
6
7
# File 'lib/hatetepe/response.rb', line 5

def request
  @request
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/hatetepe/response.rb', line 5

def status
  @status
end

Instance Method Details

#[](idx) ⇒ Object



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

def [](idx)
  to_a[idx]
end

#failure?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/hatetepe/response.rb', line 16

def failure?
  status.between? 400, 599
end

#success?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/hatetepe/response.rb', line 12

def success?
  status.between? 100, 399
end

#to_aObject



20
21
22
# File 'lib/hatetepe/response.rb', line 20

def to_a
  [status, headers, body]
end