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, #contains_input_placeholder?, #qualified_names_in_context, #raise_evaluation_error
Instance Method Details
#eval(context = {}) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/feel/nodes.rb', line 167 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 |