Currency: Ruby Package for FX and MoneySubmitted by Kurt on October 29, 2006 - 10:03pm.
See: http://rubyforge.org/projects/currency/ The RubyForge package currency Currency::Money uses a scaled integer representation of the monetary value and performs accurate conversions to and from string values. Currency::Currency Currency::Exchange::Base
require 'currency'
require 'currency/exchange/xe'
usd = Currency::Money('6.78', :USD)
puts "usd = #{usd.format}"
cad = usd.convert(:CAD)
puts "cad = #{cad.format}"
The example above, uses Currency::Exchange::Xe Future enhancements will include:
This package also contains ActiveRecord support for money values: require 'currency' require 'currency/active_record' class Entry < ActiveRecord::Base money :amount end The first file release is pending, so please visit the svn repo at: svn checkout svn://rubyforge.org/var/svn/currency/currency/trunk For more examples, see:
I'd love to hear your feedback on this module. -- Kurt |
||
Ruby Gem available
A rubygem for this package is now available on http://rubyforge.org:
-- Kurt