Class: FEEL::SimplePositiveUnaryTest

Inherits:
Node
  • Object
show all
Defined in:
lib/feel/nodes.rb

Overview

  1. simple positive unary test =

7.a [ “<” | “<=” | “>” | “>=” ] , endpoint | 7.b interval ;

Instance Method Summary collapse

Methods inherited from Node

#access_property, #qualified_names_in_context, #raise_evaluation_error

Instance Method Details

#eval(context = {}) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/feel/nodes.rb', line 126

def eval(context = {})
  operator = head.text_value.strip
  endpoint = tail.eval(context)

  case operator
  when "<"
    ->(input) { input.nil? || endpoint.nil? ? nil : input < endpoint }
  when "<="
    ->(input) { input.nil? || endpoint.nil? ? nil : input <= endpoint }
  when ">"
    ->(input) { input.nil? || endpoint.nil? ? nil : input > endpoint }
  when ">="
    ->(input) { input.nil? || endpoint.nil? ? nil : input >= endpoint }
  else
    ->(input) { input == endpoint }
  end
end