Class: BubbleWrap::HTTP::Response

Inherits:
Object
  • Object
show all
Defined in:
motion/http.rb

Overview

Response class wrapping the results of a Query’s response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values = {}) ⇒ Response

Returns a new instance of Response.



62
63
64
# File 'motion/http.rb', line 62

def initialize(values={})
  self.update(values)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



57
58
59
# File 'motion/http.rb', line 57

def body
  @body
end

#error_messageObject

Returns the value of attribute error_message.



59
60
61
# File 'motion/http.rb', line 59

def error_message
  @error_message
end

#headersObject (readonly)

Returns the value of attribute headers.



58
59
60
# File 'motion/http.rb', line 58

def headers
  @headers
end

#status_codeObject

Returns the value of attribute status_code.



59
60
61
# File 'motion/http.rb', line 59

def status_code
  @status_code
end

#urlObject (readonly)

Returns the value of attribute url.



60
61
62
# File 'motion/http.rb', line 60

def url
  @url
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'motion/http.rb', line 72

def ok?
  status_code.to_s =~ /20\d/ ? true : false
end

#to_sObject Also known as: description



76
77
78
# File 'motion/http.rb', line 76

def to_s
  "#<#{self.class}:#{self.object_id} - url: #{self.url}, body: #{self.body}, headers: #{self.headers}, status code: #{self.status_code}, error message: #{self.error_message} >"
end

#update(values) ⇒ Object



66
67
68
69
70
# File 'motion/http.rb', line 66

def update(values)
  values.each do |k,v|
    self.instance_variable_set("@#{k}", v)
  end
end