The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Locale::Object::Currency::Converter - convert between currencies

VERSION

0.11

DESCRIPTION

Locale::Object::Currency::Converter allows you to convert between values of currencies represented by Locale::Object::Currency objects.

SYNOPSIS

    use Locale::Object::Currency;
    use Locale::Object::Currency::Converter;
    
    my $usd = Locale::Object::Currency->new( code => 'USD' );
    my $gbp = Locale::Object::Currency->new( code => 'GBP' );
    my $eur = Locale::Object::Currency->new( code => 'EUR' );
    my $jpy = Locale::Object::Currency->new( code => 'JPY' );
    
    my $converter = Locale::Object::Currency::Converter->new(
                                                from    => $usd,
                                                to      => $gbp,
                                                service => 'XE'
                                               );

    my $result    = $converter->convert(5);
    my $rate      = $converter->rate;
    my $timestamp = $converter->timestamp;
    
    $converter->from($eur);
    $converter->to($jpy);
    $converter->service('Yahoo');

    $converter->refresh;

PREREQUISITES

This module requires Finance::Currency::Convert::XE and Finance::Currency::Convert::Yahoo.

METHODS

new()

    my $converter = Locale::Object::Currency::Converter->new();

Creates a new converter object. With no arguments, creates a blank object. Possible arguments are from, to and service, all or none of which may be given. from and to must be Locale::Object::Currency objects. service must be one of either 'XE' or 'Yahoo', to specify the conversion should be done by http://xe.com/ucc/ or http://finance.yahoo.com/ respectively.

from()

    $converter->from($eur);

Sets a currency to do conversions from. Takes a Locale::Object::Currency object.

to()

    $converter->to($jpy);

Sets a currency to do conversions to. Takes a Locale::Object::Currency object.

service()

    $converter->service('Yahoo');

Sets which currency conversion service to use.

convert()

    my $result = $converter->convert(5);

Does the currency conversion. Takes a numeric argument representng the amount of the 'from' currency to convert into the 'to' currency, gives the result. Will croak if you didn't select a conversion service, 'from' and 'to' currency when you did new() or afterwards with the associated methods (see above).

rate()

    my $rate = $converter->rate;

Returns the conversion rate between your 'from' currency and your 'to' currency, as of the time you last did a conversion. If you haven't done any conversions yet, will do one first (the result for converting 1 unit of a currency into another currency is the rate) and give you that.

timestamp()

    my $timestamp = $converter->timestamp;

Returns the time timestamp of the last time the currency exchange rate was stored, either the last time you did a convert() or a refresh().

refresh()

    $converter->refresh;
    

Will update the stored conversion rate and timestamp by doing another conversion. Doesn't return anything.

AUTHOR

Earle Martin <EMARTIN@cpan.org>

http://purl.oclc.org/net/earlemartin/

CREDITS

See the credits for Locale::Object.

LEGAL

Copyright 2003 Fotango Ltd. All rights reserved. http://opensource.fotango.com/

This module is released under the same license as Perl itself, and is provided on an "as is" basis. The author and Fotango Ltd make no warranties of any kind, either expressed or implied, as to the accuracy and/or utility of any results obtained from its use. However, if you do find something wrong with the results, please let the author know. Thanks.