NAME
    Parse::FireDiamond - Parse Fire Diamond (NFPA 704) notation

VERSION
    This document describes version 0.004 of Parse::FireDiamond (from Perl
    distribution Parse-FireDiamond), released on 2023-03-29.

SYNOPSIS
     use Parse::FireDiamond qw(
         parse_fire_diamond_text
     );

     my $res = parse_fire_diamond_text(notation => 'H3/F2/R1/');

DESCRIPTION
    Keywords: chemicals, materials, hazardous, safety.

FUNCTIONS
  parse_fire_diamond_text_notation
    Usage:

     parse_fire_diamond_text_notation(%args) -> [$status_code, $reason, $payload, \%result_meta]

    Parse Fire Diamond (NFPA 704) text notation.

    Examples:

    *   Parse the fire diamond for citric acid:

         parse_fire_diamond_text_notation(notation => "H2/F1/R0/");

        Result:

         [
           200,
           "OK (parsed)",
           {
             fire_hazard_meaning   => "above 93 \xC2\xB0C",
             fire_hazard_number    => 1,
             health_hazard_meaning => "hazardous",
             health_hazard_number  => 2,
             reactivity_meaning    => "stable",
             reactivity_number     => 0,
           },
           {
             "func.fire_hazard_explanation"   => "Materials that require considerable preheating, under all ambient temperature conditions, before ignition and combustion can occur (e.g. mineral oil, ammonia, ethylene glycol). Includes some finely divided suspended solids that do not require heating before ignition can occur. Flash point at or above 93.3 \xC2\xB0C (200 \xC2\xB0F).",
             "func.health_hazard_explanation" => "Intense or continued but not chronic exposure could cause temporary incapacitation or possible residual injury (e.g. diethyl ether, ammonium phosphate, carbon dioxide, chloroform, DEET).",
             "func.reactivity_explanation"    => "Normally stable, even under fire exposure conditions, and is not reactive with water (e.g. helium, N2, carbon dioxide)",
           },
         ]

    *   Parse the fire diamond for sucrose:

         parse_fire_diamond_text_notation(notation => "H0/F1/R0/");

        Result:

         [
           200,
           "OK (parsed)",
           {
             fire_hazard_meaning   => "above 93 \xC2\xB0C",
             fire_hazard_number    => 1,
             health_hazard_meaning => "normal material",
             health_hazard_number  => 0,
             reactivity_meaning    => "stable",
             reactivity_number     => 0,
           },
           {
             "func.fire_hazard_explanation"   => "Materials that require considerable preheating, under all ambient temperature conditions, before ignition and combustion can occur (e.g. mineral oil, ammonia, ethylene glycol). Includes some finely divided suspended solids that do not require heating before ignition can occur. Flash point at or above 93.3 \xC2\xB0C (200 \xC2\xB0F).",
             "func.health_hazard_explanation" => "Poses no health hazard, no precautions necessary and would offer no hazard beyond that of ordinary combustible materials (e.g. wood, sugar, salt, propylene glycol)",
             "func.reactivity_explanation"    => "Normally stable, even under fire exposure conditions, and is not reactive with water (e.g. helium, N2, carbon dioxide)",
           },
         ]

    *   Parse the fire diamond for sulfuric acid:

         parse_fire_diamond_text_notation(notation => "H3/F0/R2/W+OX");

        Result:

         [
           200,
           "OK (parsed)",
           {
             fire_hazard_meaning   => "not flammable",
             fire_hazard_number    => 0,
             health_hazard_meaning => "extreme danger",
             health_hazard_number  => 3,
             reactivity_meaning    => "violent reaction",
             reactivity_number     => 2,
             specific_hazards      => [
                                        { meaning => "reacts with water", symbol => "W" },
                                        { meaning => "oxidizer", symbol => "OX" },
                                      ],
           },
           {
             "func.fire_hazard_explanation"   => "Materials that will not burn under typical fire conditions (e.g. carbon tetrachloride, silicon dioxide, perfluorohexane), including intrinsically noncombustible materials such as concrete, stone, and sand. Materials that will not burn in air unless exposed to a temperature of 820 \xC2\xB0C (1,500 \xC2\xB0F) for more than 5 minutes.",
             "func.health_hazard_explanation" => "Short exposure could cause serious temporary or moderate residual injury (e.g. liquid hydrogen, sulfuric acid, calcium hypochlorite, carbon monoxide, hexafluorosilicic acid, zinc chloride, sodium hydroxide)",
             "func.reactivity_explanation"    => "Undergoes violent chemical change at elevated temperatures and pressures, reacts violently with water, or may form explosive mixtures with water (e.g. white phosphorus, potassium, sodium)",
             "func.specific_hazards"          => [
                                                   {
                                                     explanation => "Reacts with water in an unusual or dangerous manner (e.g. caesium, sodium, diborane, sulfuric acid)",
                                                     symbol => "W",
                                                   },
                                                   {
                                                     explanation => "allows chemicals to burn without an air supply (e.g. potassium perchlorate, ammonium nitrate, hydrogen peroxide)",
                                                     symbol => "OX",
                                                   },
                                                 ],
           },
         ]

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   notation* => *str*

        (No description)

    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/Parse-FireDiamond>.

SOURCE
    Source repository is at
    <https://github.com/perlancar/perl-Parse-FireDiamond>.

SEE ALSO
    Credits: explanation text are taken from Wikipedia page
    <https://en.wikipedia.org/wiki/NFPA_704>.

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,
    Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two
    other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps
    required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE
    This software is copyright (c) 2023 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=Parse-FireDiamond>

    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.