Mango::BSON::Number(3pm)

Mango::BSON::Number3pm

Numerical types

Usage

  use Mango::BSON;
  use Mango::BSON::Number;
  my $number = Mango::BSON::Number->new(666, Mango::BSON::INT64);
  say $number;

Overview

Mango::BSON::Number is a container for numerical values with a strict type.

Methods

Mango::BSON::Number inherits all methods from Mojo::Base and implements the following new ones.

new

  my $number = Mango::BSON::Number->new(3.14, Mango::BSON::DOUBLE);

Construct a new Mango::BSON::Number object. Croak if the value is incompatible with the given type. The 3 supported types are "DOUBLE", "INT32" and "INT64".

To_json

  my $num = $obj->TO_JSON;

Return the numerical value.

to_string

  my $str = $num->to_string;

Return the value as a string.

isa_number

  my $flags = Mango::BSON::Number::isa_number(25);

Determine if the given variable is a number by looking at the internal flags of the perl scalar object.

Return "undef" if the value is not a number, or a non-null value otherwise. This value contains flags which can be used for finer analysis of the scalar.

guess_type

  my $mongo_type = Mango::BSON::Number::guess_type(25);

Chose which BSON type to use to encode the given numeric value. Possible types are: "Mango::BSON::DOUBLE", "Mango::BSON::INT32" or "Mango::BSON::INT64".

Return "undef" if the given value is not a number.

Operators

Mango::BSON::Time overloads the following operators.

bool

  my $bool = !!$num;

stringify

  my $str = "$num";

Alias for "to_string".

Releases

5 releases since Debian 9 (Stretch); the text changed 2 times.

  1. 9
  2. 10
  3. 11–13

From libmango-perl 1.30-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.