Class: WAB::Impl::Between
- Defined in:
- lib/wab/impl/exprs/between.rb
Overview
Matches numeric nodes between a minimum and maximum value. By default the matches are inclusive of the minimum and maximum. The optional arguments allow the inclusivity to be changed to exclusive separately for the minimum and maximum. By default the min_incl and max_incl are true. If set to false the corresponding limit becomes exclusive. An error is returned if used with non-numeric minimum or maximum.
Instance Method Summary collapse
- #eval(data) ⇒ Object
-
#initialize(path, min, max, min_incl = true, max_incl = true) ⇒ Between
constructor
Creates a new instance with the provided parameters.
- #native ⇒ Object
Constructor Details
#initialize(path, min, max, min_incl = true, max_incl = true) ⇒ Between
Creates a new instance with the provided parameters.
- path
-
path to the value to compare
- min
-
minimum
- max
-
maximum
- min_incl
-
minimum inclusive flag
- max_incl
-
maximum inclusive flag
20 21 22 23 24 25 26 |
# File 'lib/wab/impl/exprs/between.rb', line 20 def initialize(path, min, max, min_incl=true, max_incl=true) super(path) @min = min @max = max @min_incl = min_incl @max_incl = max_incl end |
Instance Method Details
#eval(data) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/wab/impl/exprs/between.rb', line 28 def eval(data) value = data.get(path) return false if (@min_incl ? value < @min : value <= @min) return false if (@max_incl ? @max < value : @max <= value) true end |
#native ⇒ Object
35 36 37 |
# File 'lib/wab/impl/exprs/between.rb', line 35 def native() ['BETWEEN', path, @min, @max, @min_incl, @max_incl] end |