NAME

Data::OFN::Common::Quantity - OFN common data object for quantity.

SYNOPSIS

use Data::OFN::Common::Quantity;

my $obj = Data::OFN::Common::Quantity->new(%params);
my $unit = $obj->unit;
my $value = $obj->value;

DESCRIPTION

Immutable data object for OFN (Otevřené formální normy) representation of quantity in the Czech Republic.

This object is actual with 2020-07-01 version of OFN basic data types standard.

METHODS

new

my $obj = Data::OFN::Common::Quantity->new(%params);

Constructor.

  • unit

    Quantity unit defined by UN/CEFACT unit common code.

    It's required.

    Default value is undef.

  • value

    Quantity value in some number form.

    It's required.

    Default value is undef.

Returns instance of object.

unit

my $unit = $obj->unit;

Get UN/CEFACT unit common code.

Returns string.

value

my $value = $obj->value;

Get value.

Returns number.

ERRORS

new():
        From Mo::utils::check_required():
                Parameter 'unit' is required.
                Parameter 'value' is required.
        From Mo::utils::CEFACT::check_cefact_unit():
                Parameter 'unit' must be a UN/CEFACT unit common code.
                        Value: %s
        From Mo::utils::Number::check_number():
                Parameter 'value' must be a number.
                        Value: %s

EXAMPLE1

use strict;
use warnings;

use Data::OFN::Common::Quantity;

my $obj = Data::OFN::Common::Quantity->new(
        'value' => 1,
        'unit' => 'KGM',
);

# Print out.
print 'Value: '.$obj->value."\n";
print 'Unit: '.$obj->unit."\n";

# Output:
# Value: 1
# Unit: KGM

DEPENDENCIES

Error::Pure Mo, Mo::utils, Mo::utils::CEFACT, Mo::utils::Number.

REPOSITORY

https://github.com/michal-josef-spacek/Data-OFN-Common

AUTHOR

Michal Josef Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

© 2023-2025 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.01