File Coverage

lib/UR/BoolExpr/Template/PropertyComparison/NotBetween.pm
Criterion Covered Total %
statement 21 22 95.4
branch 6 8 75.0
condition 5 9 55.5
subroutine 5 5 100.0
pod n/a
total 37 44 84.0


line stmt bran cond sub pod time code
1             package UR::BoolExpr::Template::PropertyComparison::NotBetween;
2              
3 1     1   61 use strict;
  1         2  
  1         28  
4 1     1   3 use warnings;
  1         1  
  1         24  
5 1     1   3 use UR;
  1         1  
  1         7  
6             our $VERSION = "0.46"; # UR $VERSION;
7              
8             UR::Object::Type->define(
9             class_name => __PACKAGE__,
10             is => ['UR::BoolExpr::Template::PropertyComparison'],
11             );
12              
13             sub _compare {
14 16     16   21 my ($self, $value, @property_value) = @_;
15 16         21 my $lower_bound = $value->[0];
16 16         18 my $upper_bound = $value->[1];
17              
18 16 100       57 my $cv_is_number = Scalar::Util::looks_like_number($lower_bound)
19             and
20             Scalar::Util::looks_like_number($upper_bound);
21              
22 1     1   5 no warnings 'uninitialized';
  1         2  
  1         110  
23 16         22 foreach my $property_value ( @property_value ) {
24 16         25 my $pv_is_number = Scalar::Util::looks_like_number($property_value);
25              
26 16 100 66     56 if ($cv_is_number and $pv_is_number) {
27 8 50 33     63 return 1 if ( $property_value < $lower_bound or $property_value > $upper_bound);
28             } else {
29 8 50 66     54 return 1 if ( $property_value lt $lower_bound or $property_value gt $upper_bound);
30             }
31             }
32 0           return '';
33             }
34              
35              
36             1;
37              
38             =pod
39              
40             =head1 NAME
41              
42             UR::BoolExpr::Template::PropertyComparison::NotBetween - perform a 'not between' test
43              
44             =head1 DESCRIPTION
45              
46             Evaluates to true of the property's value is not between the lower and upper bounds, inclusive.
47             If the property returns multiple values, this comparison returns true if any of the values are
48             outside the bounds.
49              
50             =cut