NAME
Convert::Pluggable - convert between various units of measurement
VERSION
Version 0.030
SYNOPSIS
convert between various units of measurement
use Convert::Pluggable;
...
my $result = $c-
convert( { 'factor' => '5', 'from_unit' => 'feet', 'to_unit' => 'inches', 'precision' => '3', } ); >
will produce '60.000'.
See Convert-Pluggable.t for many more example uses.
See https://ddh5.duckduckgo.com/?q=10000+minutes+in+microseconds for test uses
EXPORT
convert
SUBROUTINES/METHODS
new()
Create a new Conversion object.
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 the only exported sub.
get_matches()
get factors for later calculating conversion
get trigger 'types' to determine if we can perform a calculation in the first place
get canoncial units for massaging output
determine if a unit may be negative
This gets some useful metadata for convert() to carry out its work.
get_units()
This is where you add new unit types so that convert() can operate on them. Currently supported units of measurement are: mass, length, time, pressure, energy, power, angle, force, temperature, digital.
parse_number()
handle numbers with special characters in them, like '6^2' and '2e3'.
AUTHOR
bradley andersen, <bradley at pvnp.us>
BUGS
Because of the base unit ('day'), time conversions are off:
e.g.: '1 year to months' yields: '1 year is 11.999 months'
add back in guard against things like: '10 inches to 5 cm'
SUPPORT
You can find documentation for this module with the perldoc command.
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
Special thanks to @mintsoft and @jagtalon
LICENSE AND COPYRIGHT
Copyright (c) 2014 Bradley Andersen. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
PRIOR ART
Bot::BasicBot::Pluggable::Module::Convert
relies on
Math::Units
TODO
add DDG massaging later if useful
better error handling
all args to functions should be hash refs!
store units data in a file?
add more unit types (digital, cooking, etc.)
support native perl numbers in queries: e.g.: '12.34e-56 cm to mm'
don't show decimals when integer answer? e.g.: '12.000' should be '12' (this may be something we leave to implementation)
add more tests and better test output
'1 year to months'
'16 years to months'
'12.34e-56 cm to mm'
'10 inches to 5 cm'
fix tests
fix this documentation!
what happens when two units have the same notation? (e.g., 'kilometer' and 'kilobyte' both can use 'K')