MouseX...ts::Num(3pm)

πŸ“¦
version 1.09 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– MouseX::NativeTraits::Num πŸ’–

okay bestie, gather round, because we're talking about MouseX::NativeTraits::Num β€” the helper trait for Num attributes, straight out of the User Contributed Perl Documentation. she's a perl 3pm page and she's here to make your numbers do little tricks. πŸŽ€


✨ NAME ✨

MouseX::NativeTraits::Num β€” Helper trait for Num attributes πŸ’…


🌸 SYNOPSIS 🌸

okay so here's the whole vibe, literally copy-paste this energy:

package Real;
use Mouse;

has 'integer' => (
    traits    => ['Number'],
    is        => 'ro',
    isa       => 'Num',
    default   => 5,
    handles   => {
        set => 'set',
        add => 'add',
        sub => 'sub',
        mul => 'mul',
        div => 'div',
        mod => 'mod',
        abs => 'abs',
    },
);

my $real = Real->new();
$real->add(5); # same as $real->integer($real->integer + 5);
$real->sub(2); # same as $real->integer($real->integer - 2);

see how clean that is?? the handles block is basically handing you a whole little math toolkit and you didn't even break a sweat. no cap. πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

so what is this actually giving? it's giving a simple numeric attribute that supports most of the basic math operations. that's it, that's the whole thing. she does numbers, she does math, she does it in place. iconic behavior honestly. ⭐


πŸ‘‘ PROVIDED METHODS πŸ‘‘

IMPORTANT NOTE BESTIE: all of these methods do in place modification of the value stored in the attribute. like, they change the actual thing. not a copy. not a vibe. the real one. and also β€” these methods are implemented within this package. πŸ’–
  • add($value) β€” adds the current value of the attribute to $value. so you're stacking it up, we love an accumulative queen. ✨
  • sub($value) β€” subtracts $value from the current value of the attribute. taking it away, respectfully. πŸ’…
  • mul($value) β€” multiplies the current value of the attribute by $value. exponential growth era. 🌈
  • div($value) β€” divides the current value of the attribute by $value. sharing is caring. 🫢
  • mod($value) β€” returns the current value of the attribute modulo $value. the remainder, the leftovers, the little bit nobody talks about but she's still there. πŸ’€
  • abs β€” sets the current value of the attribute to its absolute value. negative thoughts? gone. only positivity now. periodt. 🌸

🧚 METHODS 🧚

these ones are just vibing here, no description given, just names, and we respect that:

  • meta
  • method_provider_class
  • helper_type

πŸ’œ SEE ALSO πŸ’œ

  • MouseX::NativeTraits β€” go read her too, she's the whole family. πŸŽ€

and that's the page bestie!! this absolute baddie of a manual was served up by perl v5.34.0, dated 2022-06-16, under the MouseX...ts::Num(3pm) banner. go forth and do math, you've got this. πŸ’–βœ¨πŸ¦‹πŸ‘‘

πŸ“¦ where this page comes from