Class: Cel::Environment
- Inherits:
-
Object
- Object
- Cel::Environment
- Defined in:
- lib/cel/environment.rb
Instance Method Summary collapse
- #check(expr) ⇒ Object
- #compile(expr) ⇒ Object
- #decode(encoded_expr) ⇒ Object
- #encode(expr) ⇒ Object
- #evaluate(expr, bindings = nil) ⇒ Object
-
#initialize(declarations = nil) ⇒ Environment
constructor
A new instance of Environment.
- #program(expr) ⇒ Object
Constructor Details
#initialize(declarations = nil) ⇒ Environment
Returns a new instance of Environment.
5 6 7 8 9 |
# File 'lib/cel/environment.rb', line 5 def initialize(declarations = nil) @declarations = declarations @parser = Parser.new @checker = Checker.new(@declarations) end |
Instance Method Details
#check(expr) ⇒ Object
27 28 29 30 |
# File 'lib/cel/environment.rb', line 27 def check(expr) ast = @parser.parse(expr) @checker.check(ast) end |
#compile(expr) ⇒ Object
11 12 13 14 15 |
# File 'lib/cel/environment.rb', line 11 def compile(expr) ast = @parser.parse(expr) @checker.check(ast) ast end |
#decode(encoded_expr) ⇒ Object
21 22 23 24 25 |
# File 'lib/cel/environment.rb', line 21 def decode(encoded_expr) ast = Encoder.decode(encoded_expr) @checker.check(ast) ast end |
#encode(expr) ⇒ Object
17 18 19 |
# File 'lib/cel/environment.rb', line 17 def encode(expr) Encoder.encode(compile(expr)) end |