Class: FEEL::Interval
- Defined in:
- lib/feel/nodes.rb
Overview
-
interval = ( open interval start | closed interval start ) , endpoint , “..” , endpoint , ( open interval end | closed interval end ) ;
Instance Method Summary collapse
Methods inherited from Node
#access_property, #qualified_names_in_context, #raise_evaluation_error
Instance Method Details
#eval(context = {}) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/feel/nodes.rb', line 155 def eval(context = {}) start = start_token.text_value finish = end_token.text_value first_val = first.eval(context) second_val = second.eval(context) return ->(_input) { nil } if first_val.nil? || second_val.nil? case [start, finish] when ["(", ")"] ->(input) { input.nil? ? nil : first_val < input && input < second_val } when ["[", "]"] ->(input) { input.nil? ? nil : first_val <= input && input <= second_val } when ["(", "]"] ->(input) { input.nil? ? nil : first_val < input && input <= second_val } when ["[", ")"] ->(input) { input.nil? ? nil : first_val <= input && input < second_val } end end |