View on
MetaCPAN
Bradley Andersen > Convert-Pluggable > Convert::Pluggable

Download:
Convert-Pluggable-0.0322.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.0322   Source  

NAME ^

Convert::Pluggable - convert between various units of measurement

VERSION ^

Version 0.0322

Authoritative version is always here: https://github.com/elohmrow/Convert-Pluggable

SYNOPSIS ^

convert between various units of measurement

IMPORTANT NOTICE - FUNCTIONALITY ADDITION ^

You my use this module standalone prior to v0.031; there the units are all hard-coded into the module:

        use Convert::Pluggable;
        my $c = new Convert::Pluggable()
        my $c->convert( { 'factor' => '5', 'from_unit' => 'feet', 'to_unit' => 'inches', 'precision' => '3', });

Starting in v0.031 you may still use this module stand-alone, but you may optionally provide as a constructor argument the name of a data file (currently only supports JSON) - then you will be able to use C::P as a service. See examples/service.pl for an example Dancer2 script. See data/units.json for an example of a valid json data set.

See t/Convert-Pluggable.t for many more example uses.

See https://ddh5.duckduckgo.com/?q=10000+minutes+in+microseconds for examples of test uses

See https://github.com/elohmrow/Convert-Pluggable for the most recent version

EXPORT ^

convert()

get_units()

SUBROUTINES/METHODS ^

new()

Create a new Conversion object.

new('/path/to/some/data.json')

Create a new Conversion object pre-loaded with serializable data to be used as a service.

convert_temperatures()

A function for converting between various temperature units. Currently supports Fahrenheit, Celsius, Kelvin, Rankine, and Raumur.

convert()

This is the workhorse. All conversion work (except for temperatures) gets done here. This is an exported sub.

get_matches()

get_units()

In versions prior to 0.031, this is where you add new unit types so that convert() can operate on them. This behavior is still supported. This is an exported sub.

Currently supported units of measurement are: mass, length, time, pressure, energy, power, angle, force, temperature, digital.

old_get_units()

If you don't pass in a data file on construction, units are gotten from a hardcoded hash in this source file.

parse_number()

handle numbers with special characters in them, like '6^2' and '2e3'. written by mwmiller.

temperature_get_factor()

This sub handles converting any value for any temperature scale to the equivalent fahrenheit value for later conversion to some other unit.

precision()

This sub takes the output of a conversion and rounds it to the specified precision. It is set by default to 3.

AUTHOR ^

bradley andersen, <bradley at pvnp.us>

SUPPORT ^

You can find documentation for this module with the perldoc command.

You can also look for information at:

ACKNOWLEDGEMENTS ^

Special thanks to @mintsoft and @jagtalon

LICENSE AND COPYRIGHT ^

Copyright (c) 2014-2016 Bradley Andersen. This program is free software; you may redistribute and/or modify it under the same terms as Perl itself.

PRIOR ART - but not really! ^

Bot::BasicBot::Pluggable::Module::Convert relies on Math::Units

Convert::Temperature

TODO ^

syntax highlighting: