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.


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

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

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body


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

def body
  @body
end

#error_messageObject

Returns the value of attribute error_message


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

def error_message
  @error_message
end

#headersObject (readonly)

Returns the value of attribute headers


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

def headers
  @headers
end

#status_codeObject

Returns the value of attribute status_code


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

def status_code
  @status_code
end

#urlObject (readonly)

Returns the value of attribute url


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

def url
  @url
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)

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

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

#to_sObject Also known as: description


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

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


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

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