« blib/lib/UR/BoolExpr/Template/PropertyComparison/LessThan.pm
↑ Summary
blib/lib/UR/ModuleBuild.pm »
| 1 | package UR::BoolExpr::Template::PropertyComparison::NotBetween; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use UR; | ||
| 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 | my ($self, $value, @property_value) = @_; | ||
| 15 | my $lower_bound = $value->[0]; | ||
| 16 | my $upper_bound = $value->[1]; | ||
| 17 | |||
| 18 | my $cv_is_number = Scalar::Util::looks_like_number($lower_bound) | ||
| 19 | and | ||
| 20 | Scalar::Util::looks_like_number($upper_bound); | ||
| 21 | |||
| 22 | no warnings 'uninitialized'; | ||
| 23 | foreach my $property_value ( @property_value ) { | ||
| 24 | my $pv_is_number = Scalar::Util::looks_like_number($property_value); | ||
| 25 | |||
| 26 | if ($cv_is_number and $pv_is_number) { | ||
| 27 | return 1 if ( $property_value < $lower_bound or $property_value > $upper_bound); | ||
| 28 | } else { | ||
| 29 | return 1 if ( $property_value lt $lower_bound or $property_value gt $upper_bound); | ||
| 30 | } | ||
| 31 | } | ||
| 32 | 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 |