Class: Supreme::Response

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

Overview

The base class for all response classes.

Direct Known Subclasses

Banklist, Error, Status, Transaction

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ Response

Returns a new instance of Response.



8
9
10
# File 'lib/supreme/response.rb', line 8

def initialize(body)
  @body = body
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

Class Method Details

.for(response_body, klass) ⇒ Object

Return an instance of a reponse class based on the contents of the body



17
18
19
20
21
22
23
24
# File 'lib/supreme/response.rb', line 17

def self.for(response_body, klass)
  body = REXML::Document.new(response_body).root
  if body.elements["/response/item"]
    ::Supreme::Error.new(body)
  else
    klass.new(body)
  end
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/supreme/response.rb', line 12

def error?
  false
end