MooseX...:Number(3pm)

๐Ÿ“ฆ
version 0.25 ยท 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

๐Ÿ’– MooseX::AttributeHelpers::Trait::Number ๐Ÿ’–

okay bestie, gather round, we're doing a User Contributed Perl Documentation moment. this one's from the MooseX...:Number(3pm) page and it's literally the cutest little numeric attribute you ever met. no cap.


โœจ NAME โœจ

MooseX::AttributeHelpers::Trait::Number โ€” it's giving... a simple numeric attribute ๐Ÿงฎโœจ


๐ŸŒธ VERSION ๐ŸŒธ

version 0.25 โ€” yeah she's been around, she's vintage, she's iconic ๐Ÿ‘‘


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

okay so here's the whole vibe, copy-paste this into your lil heart:

package Real;
use Moose;
use MooseX::AttributeHelpers;

has 'integer' => (
    metaclass => 'Number',
    is        => 'ro',
    isa       => 'Int',
    default   => sub { 5 },
    provides  => {
        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);

like... look at her go. the metaclass => 'Number', the provides hash handing out all those math methods like friendship bracelets ๐Ÿซถ. main character behavior fr fr.


๐Ÿ’… DESCRIPTION ๐Ÿ’…

So basically this trait gives you a simple numeric attribute, and she supports most of the basic math operations. that's it, that's the whole pitch. lowkey perfect, highkey useful. ๐Ÿฆ‹


๐ŸŒˆ METHODS ๐ŸŒˆ

the whole squad, no notes:

  • meta
  • helper_type
  • method_constructors

โญ PROVIDED METHODS โญ

๐Ÿšจ important bestie alert ๐Ÿšจ all of these methods do in place modification of the value stored in the attribute. like, they're changing the actual value, not handing you back a copy. so don't be surprised, okay? ๐Ÿ˜ญ
  • set ($value) โ€” an alternate way to set the value. the side door to the same house ๐Ÿšช
  • add ($value) โ€” adds the current value of the attribute to $value. math but make it cute โž•
  • sub ($value) โ€” subtracts the current value of the attribute to $value. (yes, "to". we're keeping the original wording, don't come for me ๐Ÿ™ˆ) โž–
  • mul ($value) โ€” multiplies the current value of the attribute to $value. times tables but slay โœ–๏ธ
  • div ($value) โ€” divides the current value of the attribute to $value. split it like a friend group in a group project โž—
  • mod ($value) โ€” modulus the current value of the attribute to $value. the remainder, the leftovers, the crumbs ๐Ÿ“
  • abs โ€” sets the current value of the attribute to its absolute value. glow up but for negatives โœจ

๐Ÿซถ SUPPORT ๐Ÿซถ

got bugs? not the vibe, but okay, here's where to go:

come hang, we don't bite, iykyk ๐Ÿ’œ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

  • Stevan Little <stevan@iinteractive.com>
  • Robert Boone

legends, honestly. periodt. ๐Ÿ’…


This software is copyright (c) 2007 by Stevan Little and Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. ๐ŸŽ€


and that's the whole page bestie, you ate it ๐ŸŒˆโœจ

this lil cutie was served to you by perl v5.34.0, dated 2022-06-15, straight from the MooseX...:Number(3pm) manual โ€” mwah, go write some numbers, love u ๐Ÿ’–๐Ÿฆ‹๐ŸŽ€

๐Ÿ“ฆ where this page comes from