Class: Predicator::Predicates::Between
- Inherits:
-
Object
- Object
- Predicator::Predicates::Between
- Defined in:
- lib/predicator/predicates/between.rb
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(value, left, right) ⇒ Between
constructor
A new instance of Between.
- #satisfied?(context = Predicator::Context.new) ⇒ Boolean
Constructor Details
#initialize(value, left, right) ⇒ Between
6 7 8 |
# File 'lib/predicator/predicates/between.rb', line 6 def initialize value, left, right @value, @left, @right = value, left, right end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
4 5 6 |
# File 'lib/predicator/predicates/between.rb', line 4 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
4 5 6 |
# File 'lib/predicator/predicates/between.rb', line 4 def right @right end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/predicator/predicates/between.rb', line 4 def value @value end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/predicator/predicates/between.rb', line 23 def == other other.kind_of?(self.class) && other.value == value && other.left == left && other.right == right end |
#satisfied?(context = Predicator::Context.new) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/predicator/predicates/between.rb', line 10 def satisfied? context=Predicator::Context.new value_node = context.node_for value left_node = context.node_for left right_node = context.node_for right method = "compare_to_#{value_node.type}" left_value = left_node.send method right_value = right_node.send method (value_node.value >= left_value) && (value_node.value <= right_value) end |