| 1 | package Aion::Type::Lim; | ||||||||||
| 2 | # Граница для Range | ||||||||||
| 3 | |||||||||||
| 4 | 9 | ▶ | use common::sense; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | use overload | ||||||||||
| 7 | 9 | ▶ | "fallback" => 1, | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 455 | ▶ | "<=>" => sub { my ($self, $other) = _up(@_); $self->{lim} == $other->{lim}? $self->{shifting} <=> $other->{shifting}: $self->{lim} <=> $other->{lim} }, | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 9 | 57 | ▶ | '""' => sub { my ($self) = @_; $self->{shifting}? "Opened[$self->{lim}]": "Closed[$self->{lim}]" }, | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 10 | 9 | ; | |||||||||
| 11 | |||||||||||
| 12 | # Конструктор | ||||||||||
| 13 | 350 | ▶ | sub from { | ||||||||
|
Subroutine
from: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 14 | 350 | my ($cls, $lim) = @_; | |||||||||
| 15 | 350 | ▶ | bless { ref $lim eq $cls? %$lim: (lim => $lim) }, $cls; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | # Преобразователь операторных аргументов | ||||||||||
| 19 | 455 | ▶ | sub _up { | ||||||||
|
Subroutine
_up: called CC=3 SCAR=11.0
| |||||||||||
| 20 | 455 | my ($self, $other, $right) = @_; | |||||||||
| 21 | 455 | ▶ | unless(UNIVERSAL::isa($other, __PACKAGE__)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 322 | $other = __PACKAGE__->from($other); | |||||||||
| 23 | 322 | ▶ | ($other, $self) = ($self, $other) if $right; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | } | ||||||||||
| 25 | 455 | return $self, $other; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | # Умесньшает сдвиг | ||||||||||
| 29 | 14 | ▶ | sub dec { | ||||||||
|
Subroutine
dec: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 30 | 14 | my ($self) = @_; | |||||||||
| 31 | 14 | ▶ | $self->{lim} == '-Inf'? '-Inf': do { $self->{shifting}--; $self } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | # Увеличивает сдвиг | ||||||||||
| 35 | 13 | ▶ | sub inc { | ||||||||
|
Subroutine
inc: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 36 | 13 | my ($self) = @_; | |||||||||
| 37 | 13 | ▶ | $self->{lim} == 'Inf'? 'Inf': do { $self->{shifting}++; $self } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 9 | 1; | |||||||||
| 41 | |||||||||||
| 42 | __END__ | ||||||||||