Class: Bluevia::Response

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

Overview

Inner class that wraps the response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponse

Returns a new instance of Response.



21
22
23
# File 'lib/bluevia/response.rb', line 21

def initialize
  @body = ""
end

Instance Attribute Details

#bodyObject

HTTP response body



15
16
17
# File 'lib/bluevia/response.rb', line 15

def body
  @body
end

#codeObject

HTTP response code



13
14
15
# File 'lib/bluevia/response.rb', line 13

def code
  @code
end

#headersObject

HTTP headers (required when creating resources)



17
18
19
# File 'lib/bluevia/response.rb', line 17

def headers
  @headers
end

#messageObject

Returns the value of attribute message.



19
20
21
# File 'lib/bluevia/response.rb', line 19

def message
  @message
end

Instance Method Details

#[](value) ⇒ Object



43
44
45
# File 'lib/bluevia/response.rb', line 43

def [](value)
  return self.instance_variable_get("@#{value}")
end

#get_value(var) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/bluevia/response.rb', line 33

def get_value(var)
  if var.instance_of?(String)
    var
  elsif var.instance_of?(Hash)
    var.to_a.join(" - ")
  else
    var
  end
end

#to_sObject



25
26
27
28
29
30
31
# File 'lib/bluevia/response.rb', line 25

def to_s
  value = String.new
  self.instance_variables.each{ |var|
    value << "#{var} : #{get_value(self.instance_variable_get(var))} \n"
  }
  value
end