Class: FEEL::UnaryTests
- Inherits:
-
LiteralExpression
- Object
- LiteralExpression
- FEEL::UnaryTests
- Defined in:
- lib/feel/unary_tests.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from LiteralExpression
#as_json, builtin_functions, #evaluate, #functions, #initialize, #named_functions, #named_variables
Constructor Details
This class inherits a constructor from FEEL::LiteralExpression
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/feel/unary_tests.rb', line 5 def id @id end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/feel/unary_tests.rb', line 5 def text @text end |
Class Method Details
.from_json(json) ⇒ Object
7 8 9 |
# File 'lib/feel/unary_tests.rb', line 7 def self.from_json(json) UnaryTests.new(id: json[:id], text: json[:text]) end |
Instance Method Details
#test(input, variables = {}) ⇒ Object
20 21 22 23 |
# File 'lib/feel/unary_tests.rb', line 20 def test(input, variables = {}) return true if text.nil? || text == "-" tree.eval(functions.merge(variables)).call(input) end |
#tree ⇒ Object
11 12 13 |
# File 'lib/feel/unary_tests.rb', line 11 def tree @tree ||= Parser.parse_test(text) end |
#valid? ⇒ Boolean
15 16 17 18 |
# File 'lib/feel/unary_tests.rb', line 15 def valid? return true if text.nil? || text == "-" tree.present? end |