/usr/share/perl5/JE/Boolean.pm is in libje-perl 0.066-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | package JE::Boolean;
our $VERSION = '0.066';
use strict;
use warnings;
use overload fallback => 1,
'""' => sub { qw< false true >[shift->[0]] },
# cmp => sub { "$_[0]" cmp $_[1] },
bool => sub { shift->[0] },
'0+' => sub { shift->[0] };
# ~~~ to do: make sure it numifies properly (as 0 or 1)
require JE::Object::Boolean;
require JE::Number;
require JE::String;
sub new {
my($class, $global, $val) = @_;
bless [!!$val, $global], $class;
}
sub prop {
if(@_ > 2) { return $_[2] } # If there is a value, just return it
my ($self, $name) = @_;
$$self[1]->prototype_for('Boolean')->prop($name);
}
sub keys {
my $self = shift;
$$self[1]->prototype_for('Boolean')->keys;
}
sub delete {1}
sub method {
my $self = shift;
$$self[1]->prototype_for('Boolean')->prop(shift)->apply(
$self,$$self[1]->upgrade(@_)
);
}
sub value { warn caller if !ref $_[0];shift->[0] }
sub TO_JSON { \(0+shift->[0]) }
sub exists { !1 }
sub typeof { 'boolean' }
sub class { 'Boolean' }
sub id { 'bool:' . shift->value }
sub primitive { 1 }
sub to_primitive { $_[0] }
sub to_boolean { $_[0] }
# $_[0][1] is the global object
sub to_string { JE::String->_new($_[0][1], qw< false true >[shift->[0]]) }
sub to_number { JE::Number->new($_[0][1], shift->[0]) }
sub to_object { JE::Object::Boolean->new($_[0][1], shift) }
sub global { $_[0][1] }
1;
__END__
=head1 NAME
JE::Boolean - JavaScript boolean value
=head1 SYNOPSIS
use JE;
use JE::Boolean;
$j = JE->new;
$js_true = new JE::Boolean $j, 1;
$js_false = new JE::Boolean $j, 0;
$js_true ->value; # returns 1
$js_false->value; # returns ""
"$js_true"; # returns "true"
$js_true->to_object; # returns a new JE::Object::Boolean
=head1 DESCRIPTION
This class implements JavaScript boolean values for JE. The difference
between this and JE::Object::Boolean is that that module implements
boolean
I<objects,> while this module implements the I<primitive> values.
The stringification and boolean operators are overloaded.
=head1 SEE ALSO
=over 4
=item L<JE>
=item L<JE::Types>
=item L<JE::Object::Boolean>
=back
|