Class: MetaCL::DSL::Expression
- Inherits:
-
Object
- Object
- MetaCL::DSL::Expression
- Defined in:
- lib/metacl/dsl/expression.rb
Instance Attribute Summary collapse
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(program, &block) ⇒ Expression
constructor
A new instance of Expression.
- #method_missing(name, *args) ⇒ Object
- #mul(index, from, to, expression) ⇒ Object
- #sum(index, from, to, expression) ⇒ Object
Constructor Details
#initialize(program, &block) ⇒ Expression
Returns a new instance of Expression.
6 7 8 9 |
# File 'lib/metacl/dsl/expression.rb', line 6 def initialize(program, &block) @program = program @tree = instance_eval(&block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
19 20 21 22 23 |
# File 'lib/metacl/dsl/expression.rb', line 19 def method_missing(name, *args) sub_expression = @program.resources.expressions_hash[name.to_sym] substitution = sub_expression.args.map.with_index { |param, index| [param, args[index]] }.to_h sub_expression.root_node.get_tree_with_substitution(substitution) end |
Instance Attribute Details
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
4 5 6 |
# File 'lib/metacl/dsl/expression.rb', line 4 def tree @tree end |
Class Method Details
.construct(program, &block) ⇒ Object
25 26 27 |
# File 'lib/metacl/dsl/expression.rb', line 25 def self.construct(program, &block) Expression.new(program, &block).tree end |