Class: SpotFeel::SimpleUnaryTests
- Defined in:
- lib/spot_feel/nodes.rb
Overview
-
simple unary tests =
14.a simple positive unary tests | 14.b “not”, “(”, simple positive unary tests, “)” | 14.c “-”;
Instance Method Summary collapse
Methods inherited from Node
#qualified_names_in_context, #raise_evaluation_error
Instance Method Details
#eval(context = {}) ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/spot_feel/nodes.rb', line 185 def eval(context = {}) if defined?(expr) && expr.present? tests = Array.wrap(expr.eval(context)) if defined?(negate) && negate.present? ->(input) { !tests.any? { |test| test.call(input) } } else ->(input) { tests.any? { |test| test.call(input) } } end else ->(_input) { true } end end |