Class: Calyx::Production::Expression
- Inherits:
-
Object
- Object
- Calyx::Production::Expression
- Defined in:
- lib/calyx/production/expression.rb
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(production, methods, registry) ⇒ Expression
constructor
A new instance of Expression.
Constructor Details
#initialize(production, methods, registry) ⇒ Expression
Returns a new instance of Expression.
4 5 6 7 8 |
# File 'lib/calyx/production/expression.rb', line 4 def initialize(production, methods, registry) @production = production @methods = methods.map { |m| m.to_sym } @registry = registry end |
Instance Method Details
#evaluate ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/calyx/production/expression.rb', line 10 def evaluate terminal = @production.evaluate.flatten.reject { |o| o.is_a?(Symbol) }.join(''.freeze) expression = @methods.reduce(terminal) do |value, method| @registry.transform(method, value) end [:expression, expression] end |