Sha256: b47bd68b91e440830526513b12a075b30b0e392c1f2c6225dd97388530a52ead

Contents?: true

Size: 415 Bytes

Versions: 1

Compression:

Stored size: 415 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'treetop'
require_relative 'boolean_expr'

# Variable interpolation in a template
class VariableName < BooleanExpr
  def content(context)
    text_value
      .split('.')
      .reduce(context) do |ctx, name|
        next nil if ctx.nil?
        ctx[name] || ctx[name.to_sym] || nil
      end
  end

  def truthy?(context)
    !!content(context)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
emerald-lang-1.0.0 lib/emerald/nodes/variable_name.rb