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 subclass provided is currently XMethods.

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

Methods
Classes and Modules
Class Units::Converter::ExchangeRate::CachedXMethods
Class Units::Converter::ExchangeRate::XMethods
Public Instance methods
get_rate()

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/facets/more/units.rb, line 374
      def get_rate
        raise NoMethodError, "undefined method `get_rate' for #{to_s}:#{self.class}"
      end