Class: Wesabe::Currency

Inherits:
BaseModel show all
Defined in:
lib/wesabe/currency.rb

Instance Attribute Summary collapse

Attributes inherited from BaseModel

#wesabe

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#get, #post

Methods included from Util

#all_or_one

Constructor Details

#initialize {|currency| ... } ⇒ Currency

Initializes a Wesabe::Currency and yields itself.

Yield Parameters:



8
9
10
# File 'lib/wesabe/currency.rb', line 8

def initialize
  yield self if block_given?
end

Instance Attribute Details

#decimal_placesObject Also known as: precision

Returns the value of attribute decimal_places.



2
3
4
# File 'lib/wesabe/currency.rb', line 2

def decimal_places
  @decimal_places
end

#delimiterObject

Returns the value of attribute delimiter.



2
3
4
# File 'lib/wesabe/currency.rb', line 2

def delimiter
  @delimiter
end

#separatorObject

Returns the value of attribute separator.



2
3
4
# File 'lib/wesabe/currency.rb', line 2

def separator
  @separator
end

#symbolObject

Returns the value of attribute symbol.



2
3
4
# File 'lib/wesabe/currency.rb', line 2

def symbol
  @symbol
end

Class Method Details

.from_xml(xml) ⇒ Wesabe::Currency

Returns a Wesabe::Currency generated from Wesabe’s API XML.

Parameters:

  • xml (Hpricot::Element)

    The <currency> element from the API.

Returns:



22
23
24
25
26
27
28
29
# File 'lib/wesabe/currency.rb', line 22

def self.from_xml(xml)
  new do |currency|
    currency.decimal_places = xml[:decimal_places].to_s.to_i
    currency.symbol         = xml[:symbol].to_s
    currency.separator      = xml[:separator].to_s
    currency.delimiter      = xml[:delimiter].to_s
  end
end

Instance Method Details

#inspectObject



31
32
33
# File 'lib/wesabe/currency.rb', line 31

def inspect
  inspect_these :symbol, :decimal_places, :separator, :delimiter
end