NAME

App::MineralUtils - Utilities related to mineral supplements

VERSION

This document describes version 0.004 of App::MineralUtils (from Perl distribution App-MineralUtils), released on 2021-08-15.

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(quantity => "mg");

    Result:

    [
      200,
      "OK",
      [
        { amount => 1, unit => "mg-mg-elem" },
        { amount => 8.84955752212389, unit => "mg-mg-citrate" },
        { amount => 6.28930817610063, unit => "mg-mg-citrate-ah" },
        { amount => 6.89655172413793, unit => "mg-mg-citrate-ah-nowfoods" },
        { amount => 7.09219858156028, unit => "mg-mg-glycinate" },
        { amount => 7.09219858156028, unit => "mg-mg-bisglycinate" },
        { amount => 10, unit => "mg-mg-bisglycinate-nowfoods" },
        { amount => 13.5135135135135, unit => "mg-mg-ascorbate" },
        { amount => 13.5135135135135, unit => "mg-mg-pidolate" },
        { amount => 12.0481927710843, unit => "mg-mg-l-threonate" },
        { amount => 1.65837479270315, unit => "mg-mg-oxide" },
      ],
      {
        "table.field_formats" => [["number", { thousands_sep => "", precision => 3 }], undef],
        "table.field_aligns"  => ["number", "left"],
        "table.fields"        => ["amount", "unit"],
      },
    ]
  • 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

  • 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.

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.

SEE ALSO

App::VitaminUtils

Physics::Unit

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.