Class: FourInfo::Response

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

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Response

Returns a new instance of Response.



3
4
5
6
7
8
# File 'lib/response.rb', line 3

def initialize(xml)
  gem 'hpricot'
  require 'hpricot'
  @xml  = xml
  @body = Hpricot.parse(xml)
end

Instance Method Details

#[](name) ⇒ Object



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

def [](name)
  nodes = (@body/name)
  1 == nodes.size ? nodes.first : nodes
end

#confirmation_codeObject



23
24
25
# File 'lib/response.rb', line 23

def confirmation_code
  self[:confcode].inner_text
end

#inspectObject



10
11
12
# File 'lib/response.rb', line 10

def inspect
  @xml.to_s
end

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  'Success' == self['message'].inner_text
end