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;
( run in 0.923 second using v1.01-cache-2.11-cpan-6aa56a78535 )