Class: Scalr::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, data) ⇒ Response

Returns a new instance of Response.



8
9
10
11
12
13
14
15
# File 'lib/scalr/response.rb', line 8

def initialize(response, data)
  @code = response.code
  @message = response.message
  if successful_request?
    @value = parse(data)
    @error = @value[:error][:message] if !success?
  end
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



6
7
8
# File 'lib/scalr/response.rb', line 6

def code
  @code
end

#errorObject

Returns the value of attribute error.



6
7
8
# File 'lib/scalr/response.rb', line 6

def error
  @error
end

#messageObject

Returns the value of attribute message.



6
7
8
# File 'lib/scalr/response.rb', line 6

def message
  @message
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/scalr/response.rb', line 6

def value
  @value
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/scalr/response.rb', line 25

def failed?
  !success?
end

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  (successful_request? && @value[:error].nil?)
end

#successful_request?Boolean

Returns:

  • (Boolean)


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

def successful_request?
  (@code == '200')
end