Aion
view release on metacpan or search on metacpan
lib/Aion/Type/Lim.pm view on Meta::CPAN
package Aion::Type::Lim;
# ÐÑаниÑа Ð´Ð»Ñ Range
use common::sense;
use overload
"fallback" => 1,
"<=>" => sub { my ($self, $other) = _up(@_); $self->{lim} == $other->{lim}? $self->{shifting} <=> $other->{shifting}: $self->{lim} <=> $other->{lim} },
'""' => sub { my ($self) = @_; $self->{shifting}? "Opened[$self->{lim}]": "Closed[$self->{lim}]" },
;
# ÐонÑÑÑÑкÑоÑ
sub from {
my ($cls, $lim) = @_;
bless { ref $lim eq $cls? %$lim: (lim => $lim) }, $cls;
}
# ÐÑеобÑазоваÑÐµÐ»Ñ Ð¾Ð¿ÐµÑаÑоÑнÑÑ
аÑгÑменÑов
sub _up {
my ($self, $other, $right) = @_;
unless(UNIVERSAL::isa($other, __PACKAGE__)) {
$other = __PACKAGE__->from($other);
($other, $self) = ($self, $other) if $right;
}
return $self, $other;
}
# УмеÑнÑÑÐ°ÐµÑ Ñдвиг
sub dec {
my ($self) = @_;
$self->{lim} == '-Inf'? '-Inf': do { $self->{shifting}--; $self }
}
# УвелиÑÐ¸Ð²Ð°ÐµÑ Ñдвиг
sub inc {
my ($self) = @_;
$self->{lim} == 'Inf'? 'Inf': do { $self->{shifting}++; $self }
}
1;
__END__
=encoding utf-8
=head1 NAME
Aion::Type::Lim - гÑаниÑа Ñо ÑмеÑением Ð´Ð»Ñ Ð¸Ð½ÑеÑвалов
=head1 SYNOPSIS
use Aion::Type::Lim;
Aion::Type::Lim->from(5) # => Closed[5]
Aion::Type::Lim->from(5)->inc # => Opened[5]
Aion::Type::Lim->from(5)->dec # => Opened[5]
my $five_min = Aion::Type::Lim->from(5)->dec;
my $five_max = Aion::Type::Lim->from(5)->inc;
$five_min == 5 # -> ""
$five_min < 5 # -> 1
$five_max > 5 # -> 1
=head1 DESCRIPTION
ÐÑедназнаÑен Ð´Ð»Ñ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ Ð¾ÑкÑÑÑÑÑ
гÑÐ°Ð½Ð¸Ñ Ð² C<Range[from, to]>.
ÐеÑеопÑеделÑÐµÑ Ð¾Ð¿ÐµÑаÑÐ¾Ñ ÑÑÐ°Ð²Ð½ÐµÐ½Ð¸Ñ C<< E<lt>=E<gt> >> из коÑоÑого вÑводÑÑÑÑ Ð¾ÑÑалÑнÑе опеÑаÑоÑÑ ÑÑавнениÑ: C<< E<lt> >>, C<< E<gt> >>, C<< E<lt>= >>, C<< E<gt>= >>, C<==>, C<...
=head1 SUBROUTINES
=head2 from ($cls, $lim)
ÐонÑÑÑÑкÑоÑ.
=head2 dec ()
УменÑÑÐ°ÐµÑ Ñдвиг.
=head2 inc ()
УвелиÑÐ¸Ð²Ð°ÐµÑ Ñдвиг.
=head1 AUTHOR
Yaroslav O. Kosmina L<mailto:dart@cpan.org>
=head1 LICENSE
â B<GPLv3>
=head1 COPYRIGHT
The Aion::Type::Lim module is copyright © 2026 Yaroslav O. Kosmina. Rusland. All rights reserved.
( run in 0.737 second using v1.01-cache-2.11-cpan-ff9377addf4 )