#!/usr/bin/ruby -w
#
# $Id: currency-lookup,v 1.2 2004/07/21 09:51:35 ianmacd Exp $
#
# A Ruby port of Perl's Finance::Quote's sample script, currency-lookup.pl.

require 'finance/currency'

# This script demonstrates how currencies can be converted using
# Finance::Currency.

# Example usage: currency-lookup EUR USD
#   (this would convert from US Dollars [$] to Euros [] )

abort "Usage: #{$0} to from [amount]\n" unless ARGV.size >= 2

to, from, amount = ARGV[0..2]
exchange_rate = Finance::Currency::convert( to.upcase, from.upcase, amount )

abort "Urgh! Nothing back\n" unless exchange_rate > 0

printf( "%s -> %s = %f\n", from, to, exchange_rate )
