This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Wed Nov 19 22:33:57 -0800 2008 | |
| |
MIT-LICENSE | Wed Nov 19 17:02:07 -0800 2008 | |
| |
README.textile | Tue Oct 20 16:06:19 -0700 2009 | |
| |
init.rb | Tue Oct 20 16:05:15 -0700 2009 | |
| |
lib/ | Tue Oct 20 16:06:19 -0700 2009 | |
| |
tasks/ | Wed Nov 19 17:02:07 -0800 2008 |
README.textile
cash_handler
cash_handler aims to be an intuitive (and useful) set of extensions and utilities to assist in handling money across different currencies for Ruby on Rails.
Requirements and Installation
- Install the hpricot gem (gem install hpricot)
- Install the cash_handler plugin (script/plugin install git://github.com/JamesBrooks/cash_handler.git)
Usage
c = CashHandler::Base.new
# Get the current exchange rate of the AUD against the USD (currency code strings are case in-sensitive, can also be symbols)
c.get('AUD')
=> 0.619099
# Get the current exchange rate of the AUD against the GBP
c.get('AUD', :against => 'GBP')
=> 0.418621272567449
# Convert
c.convert(10, :aud, :usd)
=> 6.19099
# Force the converstion rates cache to reload currencies
c.cache.expire
# The CashHandler::Cache has a default cache life of one day, this can be overridden in one of two ways
# Upon creation
c = CashHandler::Base.new(:ttl => 30.minutes)
# During operation
c.cache.ttl = 30.minutes
Backup rates in case x-rates.com is inaccessible
You may configure cash_handler to create a backup file every time it pulls rates from x-rates.com. In the event that x-rates.com is inaccessible, the rates stored in the backup file will be used.
# Configure cash_handler to persist rates to our app's log directory
c = CashHandler::Base.new(:backup_rates_file_location => "#{RAILS_ROOT}/tmp/rates.yml")
Copyright and License
Copyright © 2008 James Brooks, released under the MIT license







