class Dhallish::Ast::TextInterpolationNode
`parts` should be a list of ruby-strings and other ast-nodes that shall be interpolated.
Attributes
parts[RW]
Public Class Methods
new(parts)
click to toggle source
# File lib/ast.rb, line 126 def initialize(parts) @parts = parts end
Public Instance Methods
compute_type(ctx)
click to toggle source
# File lib/ast.rb, line 130 def compute_type(ctx) parts.each_with_index { |part, idx| assert ("TextInterpolationNode: expression at index #{idx} not a Text") { part.is_a? String or part.compute_type(ctx) == Types::Text } } Types::Text end
evaluate(ctx)
click to toggle source
# File lib/ast.rb, line 137 def evaluate(ctx) tmp = @parts.reduce("") { |str, part| if part.is_a? String str + part else val = part.evaluate ctx str + val end } tmp end