MoreMoney allows you to handle money without having to use a float/decimal field to store the amount in the database.
MoreMoney is a fork of the original Money gem written by Tobias Luetke
The original project can be found at: http://rubyforge.org/projects/money/
Main differences from the original gem are the capability to manage the nil value, an increased flexibility in formatting and the support for any currency
Usage example:require 'more_money'
#add the US dollar currency
MoreMoney::Money.add_currency({:code => 'USD', :symbol => '$', :description => 'us_dollar'})
#add the british pound
MoreMoney::Money.add_currency({:code => 'GBP', :symbol => '£', :description => 'gb_pound'})
#now is possible to instantiate some objects
ten_pounds = MoreMoney::Money.gp_pound(1000)
ten_bucks = MoreMoney::Money.us_dollar(1000)
ten_pounds.format
=> "£ 10.00"
ten_bucks.format
=> "$ 10.00"
http://moremoney.rubyforge.org/docs
No comments:
Post a Comment