Class: GoogleCheckout::MerchantCalculation

Inherits:
Object
  • Object
show all
Defined in:
lib/google-checkout/merchant_calculation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ MerchantCalculation

:nodoc:



11
12
13
# File 'lib/google-checkout/merchant_calculation.rb', line 11

def initialize(doc) # :nodoc:
  @doc = doc
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/google-checkout/merchant_calculation.rb', line 19

def method_missing(method_name, *args)
  element_name = method_name.to_s.gsub(/_/, '-')
  if element = (@doc.at element_name)
    if element.respond_to?(:inner_html)
      return element.inner_html
    end
  end
  super
end

Instance Attribute Details

#docObject

Returns the value of attribute doc.



4
5
6
# File 'lib/google-checkout/merchant_calculation.rb', line 4

def doc
  @doc
end

Class Method Details

.parse(raw_xml) ⇒ Object



6
7
8
9
# File 'lib/google-checkout/merchant_calculation.rb', line 6

def self.parse(raw_xml)
  doc = Hpricot.XML(raw_xml)
  return new(doc)
end

Instance Method Details

#address_idObject



15
16
17
# File 'lib/google-checkout/merchant_calculation.rb', line 15

def address_id
  @doc.at('anonymous-address').attributes['id']
end