| 1 | package Dallycot::Value::Boolean; | ||||||||||
| 2 | 30 | our $AUTHORITY = 'cpan:JSMITH'; | |||||||||
| 3 | |||||||||||
| 4 | # ABSTRACT: True or False | ||||||||||
| 5 | |||||||||||
| 6 | 30 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 30 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 30 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 30 | ▶ | use parent 'Dallycot::Value::Any'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 30 | ▶ | use Promises qw(deferred); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 30 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 30 | Readonly my $TRUE => bless [ !!1 ] => __PACKAGE__; | |||||||||
| 17 | 30 | Readonly my $FALSE => bless [ !!0 ] => __PACKAGE__; | |||||||||
| 18 | |||||||||||
| 19 | sub new { | ||||||||||
| 20 | 169 | ▶ | my ( $class, $f ) = @_; | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 21 | |||||||||||
| 22 | 169 | ▶ | return $f ? $TRUE : $FALSE; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | sub to_rdf { | ||||||||||
| 26 | 0 | ▶ | my( $self, $model ) = @_; | ||||||||
|
Subroutine
to_rdf: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | return RDF::Trine::Node::Literal->new( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | $self->[0] ? 'true' : 'false', | ||||||||||
| 30 | '', | ||||||||||
| 31 | $model -> meta_uri('xsd:boolean') | ||||||||||
| 32 | ); | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | sub as_text { | ||||||||||
| 36 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
as_text: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | if ( $self->[0] ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | return 'true'; | |||||||||
| 40 | } | ||||||||||
| 41 | else { | ||||||||||
| 42 | 0 | return 'false'; | |||||||||
| 43 | } | ||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | sub id { | ||||||||||
| 47 | 0 | ▶ | if ( shift->value ) { | ||||||||
|
Subroutine
id: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||
| 48 | 0 | return "true^^Boolean"; | |||||||||
| 49 | } | ||||||||||
| 50 | else { | ||||||||||
| 51 | 0 | return "false^^Boolean"; | |||||||||
| 52 | } | ||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | sub calculate_length { | ||||||||||
| 56 | 0 | ▶ | my ( $self, $engine ) = @_; | ||||||||
|
Subroutine
calculate_length: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 57 | |||||||||||
| 58 | 0 | return $engine->ONE; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | sub is_equal { | ||||||||||
| 62 | 0 | ▶ | my ( $self, $engine, $other ) = @_; | ||||||||
|
Subroutine
is_equal: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 63 | |||||||||||
| 64 | 0 | my $d = deferred; | |||||||||
| 65 | |||||||||||
| 66 | 0 | $d->resolve( $self->value == $other->value ); | |||||||||
| 67 | |||||||||||
| 68 | 0 | return $d; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | sub is_less { | ||||||||||
| 72 | 0 | ▶ | my ( $self, $engine, $other ) = @_; | ||||||||
|
Subroutine
is_less: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 73 | |||||||||||
| 74 | 0 | my $d = deferred; | |||||||||
| 75 | |||||||||||
| 76 | 0 | $d->resolve( $self->value < $other->value ); | |||||||||
| 77 | |||||||||||
| 78 | 0 | return $d; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | sub is_less_or_equal { | ||||||||||
| 82 | 0 | ▶ | my ( $self, $engine, $other ) = @_; | ||||||||
|
Subroutine
is_less_or_equal: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 83 | |||||||||||
| 84 | 0 | my $d = deferred; | |||||||||
| 85 | |||||||||||
| 86 | 0 | $d->resolve( $self->value <= $other->value ); | |||||||||
| 87 | |||||||||||
| 88 | 0 | return $d; | |||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | sub is_greater { | ||||||||||
| 92 | 0 | ▶ | my ( $self, $engine, $other ) = @_; | ||||||||
|
Subroutine
is_greater: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 93 | |||||||||||
| 94 | 0 | my $d = deferred; | |||||||||
| 95 | |||||||||||
| 96 | 0 | $d->resolve( $self->value > $other->value ); | |||||||||
| 97 | |||||||||||
| 98 | 0 | return $d->promise; | |||||||||
| 99 | } | ||||||||||
| 100 | |||||||||||
| 101 | sub is_greater_or_equal { | ||||||||||
| 102 | 0 | ▶ | my ( $self, $engine, $other ) = @_; | ||||||||
|
Subroutine
is_greater_or_equal: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 103 | |||||||||||
| 104 | 0 | my $d = deferred; | |||||||||
| 105 | |||||||||||
| 106 | 0 | $d->resolve( $self->value >= $other->value ); | |||||||||
| 107 | |||||||||||
| 108 | 0 | return $d; | |||||||||
| 109 | } | ||||||||||
| 110 | |||||||||||
| 111 | 30 | 1; | |||||||||