Class: Shove::Http::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, message, error = false) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
# File 'lib/shove/http/response.rb', line 7

def initialize status, message, error=false
  self.status = status.to_i
  self.message = message
  self.error = error
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



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

def error
  @error
end

#messageObject

Returns the value of attribute message.



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

def message
  @message
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#error?Boolean

was there an error with the request?

Returns:

  • (Boolean)


14
15
16
# File 'lib/shove/http/response.rb', line 14

def error?
  error
end

#parseObject

parse a json response



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

def parse
  @parsed ||= Yajl::Parser.new(:symbolize_keys => true).parse(message)
end

#to_hashObject

alias parse



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

def to_hash
  parse
end