NAME
App::MineralUtils - Utilities related to mineral supplements
VERSION
This document describes version 0.007 of App::MineralUtils (from Perl distribution App-MineralUtils), released on 2021-12-11.
DESCRIPTION
This distributions provides the following command-line utilities:
FUNCTIONS
convert_magnesium_unit
Usage:
convert_magnesium_unit(%args) -> [$status_code, $reason, $payload, \%result_meta]
Convert a magnesium quantity from one unit to another.
Examples:
Show all possible conversions:
convert_magnesium_unit();
Result:
[ 200, "OK", [ { amount => 1, unit => "mg-mg-elem", summary => "Elemental magnesium, in milligrams", }, { amount => 8.84955752212389, unit => "mg-mg-citrate", summary => "Magnesium citrate (C6H6MgO7), in milligrams", }, { amount => 6.28930817610063, unit => "mg-mg-citrate-ah", summary => "Magnesium citrate anhydrous (C6H5Mg3O7), in milligrams", }, { amount => 6.89655172413793, unit => "mg-mg-citrate-ah-nowfoods", summary => "Magnesium citrate in NOW Foods supplement (anhydrous, C6H5Mg3O7, 90.9% pure, contains citric acid etc), in milligrams", }, { amount => 7.09219858156028, unit => "mg-mg-glycinate", summary => "Magnesium glycinate/bisglycinate (C4H8MgN2O4), in milligrams", }, { amount => 7.09219858156028, unit => "mg-mg-bisglycinate", summary => "Magnesium glycinate/bisglycinate (C4H8MgN2O4), in milligrams", }, { amount => 10, unit => "mg-mg-bisglycinate-nowfoods", summary => "Magnesium bisglycinate in NOW Foods supplement (C4H8MgN2O4, 70.5% pure, contains citric acid etc), in milligrams", }, { amount => 15.3846153846154, unit => "mg-mg-ascorbate", summary => "Magnesium ascorbate (C12H14MgO12), in milligrams", }, { amount => 11.4942528735632, unit => "mg-mg-pidolate", summary => "Magnesium pidolate (C10H12MgN2O6), in milligrams", }, { amount => 12.0481927710843, unit => "mg-mg-l-threonate", summary => "Magnesium L-threonate (C8H14MgO10), in milligrams", }, { amount => 1.65837479270315, unit => "mg-mg-oxide", summary => "Magnesium oxide (MgO), in milligrams", }, { amount => 9.80392156862745, unit => "mg-mg-lactate-dihydrate", summary => "Magnesium lactate dihydrate (C6H14MgO8), in milligrams", }, ], { "table.fields" => ["amount", "unit", "summary"], "table.field_formats" => [ ["number", { precision => 3, thousands_sep => "" }], undef, undef, ], "table.field_aligns" => ["number", "left", "left"], }, ]
Find out how many milligrams of elemental magnesium is in 1000mg of pure magnesium l-threonate (but note that a supplement product might not contain 100%-pure compound):
convert_magnesium_unit(quantity => "1000 mg-mg-l-threonate", to_unit => "mg-mg-elem");
Result:
[200, "OK", 83, {}]
Find out how many milligrams of elemental magnesium is in 3g (1 recommended serving) of NOW Foods magnesium citrate powder (magnesium content is as advertised on the label):
convert_magnesium_unit( quantity => "3000 mg-mg-citrate-ah-nowfoods", to_unit => "mg-mg-elem" );
Result:
[200, "OK", 435, {}]
Find out how many milligrams of elemental magnesium is in 2.5g (1 recommended serving) of NOW Foods magnesium bisglycinate powder (magnesium content is as advertised on the label):
convert_magnesium_unit( quantity => "2500 mg-mg-bisglycinate-nowfoods", to_unit => "mg-mg-elem" );
Result:
[200, "OK", 250, {}]
If target unit is not specified, will show all known conversions.
This function is not exported.
Arguments ('*' denotes required arguments):
quantity => str (default: "1 mg")
to_unit => str
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.
Return value: (any)
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/App-MineralUtils.
SOURCE
Source repository is at https://github.com/perlancar/perl-App-MineralUtils.
SEE ALSO
AUTHOR
perlancar <perlancar@cpan.org>
CONTRIBUTING
To contribute, you can send patches by email/via RT, or send pull requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required beyond that are considered a bug and can be reported to me.
COPYRIGHT AND LICENSE
This software is copyright (c) 2021 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
BUGS
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-MineralUtils
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.