1Mango::BSON::Number(3)User Contributed Perl DocumentationMango::BSON::Number(3)
2
3
4
6 Mango::BSON::Number - Numerical types
7
9 use Mango::BSON;
10 use Mango::BSON::Number;
11
12 my $number = Mango::BSON::Number->new(666, Mango::BSON::INT64);
13 say $number;
14
16 Mango::BSON::Number is a container for numerical values with a strict
17 type.
18
20 Mango::BSON::Number inherits all methods from Mojo::Base and implements
21 the following new ones.
22
23 new
24 my $number = Mango::BSON::Number->new(3.14, Mango::BSON::DOUBLE);
25
26 Construct a new Mango::BSON::Number object. Croak if the value is
27 incompatible with the given type. The 3 supported types are "DOUBLE",
28 "INT32" and "INT64".
29
30 TO_JSON
31 my $num = $obj->TO_JSON;
32
33 Return the numerical value.
34
35 to_string
36 my $str = $num->to_string;
37
38 Return the value as a string.
39
40 isa_number
41 my $flags = Mango::BSON::Number::isa_number(25);
42
43 Determine if the given variable is a number by looking at the internal
44 flags of the perl scalar object.
45
46 Return "undef" if the value is not a number, or a non-null value
47 otherwise. This value contains flags which can be used for finer
48 analysis of the scalar.
49
50 guess_type
51 my $mongo_type = Mango::BSON::Number::guess_type(25);
52
53 Chose which BSON type to use to encode the given numeric value.
54 Possible types are: "Mango::BSON::DOUBLE", "Mango::BSON::INT32" or
55 "Mango::BSON::INT64".
56
57 Return "undef" if the given value is not a number.
58
60 Mango::BSON::Time overloads the following operators.
61
62 bool
63 my $bool = !!$num;
64
65 stringify
66 my $str = "$num";
67
68 Alias for "to_string".
69
71 Mango, Mojolicious::Guides, <http://mojolicio.us>.
72
73
74
75perl v5.38.0 2023-07-20 Mango::BSON::Number(3)