Class: Cel::Program
- Inherits:
-
Object
- Object
- Cel::Program
- Defined in:
- lib/cel/program.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Instance Method Summary collapse
- #disable_cel_conversion ⇒ Object
- #evaluate(ast) ⇒ Object (also: #call)
-
#initialize(context, environment) ⇒ Program
constructor
A new instance of Program.
- #with_extra_context(context) ⇒ Object
Constructor Details
#initialize(context, environment) ⇒ Program
Returns a new instance of Program.
7 8 9 10 11 |
# File 'lib/cel/program.rb', line 7 def initialize(context, environment) @context = context @environment = environment @convert_to_cel = true end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/cel/program.rb', line 5 def context @context end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
5 6 7 |
# File 'lib/cel/program.rb', line 5 def environment @environment end |
Instance Method Details
#disable_cel_conversion ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/cel/program.rb', line 38 def disable_cel_conversion convert_to_cel = @convert_to_cel begin @convert_to_cel = false yield(convert_to_cel) ensure @convert_to_cel = convert_to_cel end end |
#evaluate(ast) ⇒ Object Also known as: call
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cel/program.rb', line 17 def evaluate(ast) case ast when Group evaluate(ast.value) when Invoke evaluate_invoke(ast) when Operation evaluate_operation(ast) when Message (ast) when Literal evaluate_literal(ast) when Identifier evaluate_identifier(ast) when Condition evaluate_condition(ast) end end |
#with_extra_context(context) ⇒ Object
13 14 15 |
# File 'lib/cel/program.rb', line 13 def with_extra_context(context) self.class.new(@context.merge(context), @environment) end |