Parent

Methods

Van::Units::Converter::ExchangeRate

Encapsulates a service for retrieving exchange rates. This is used by Converter.register_currency. An instance of this class behaves like a Numeric when used in calculations. This class is used to look up exchange rates lazily.

This class is not supposed to be instantiated by itself. Instead a subclass should be created that defines the method get_rate. The only subclasses provided are currently XMethods and CachedXMethods.

To be found automatically from YAML files, exchange services should be located under Units::Converter::ExchangeRate.

Public Instance Methods

get_rate() click to toggle source

This method should be overridden in subclasses to return the exchange rate represented by this object. The unit in question is available as a String in the instance variable @curr. The rate should be calculated against an arbitrary but fixed base currency. The rate should be such that the following would be true

  1 * curr = rate * base_curr

This function should return nil if the currency is not supported by this retrieval service. It should not raise an exception.

    # File lib/van/units/currency.rb, line 58
58:       def get_rate
59:         raise NoMethodError, "undefined method `get_rate' for #{to_s}:#{self.class}"
60:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.