Sha256: ecbabef4876ea2433af761e60fed6f5eb3def2fd06d56472cc3321e024be6f4f
Contents?: true
Size: 989 Bytes
Versions: 2
Compression:
Stored size: 989 Bytes
Contents
require_relative '../exceptions' require 'dentaku/string_casing' module Dentaku module AST class Identifier < Node include StringCasing attr_reader :identifier, :case_sensitive def initialize(token, options = {}) @case_sensitive = options.fetch(:case_sensitive, false) @identifier = standardize_case(token.value) end def value(context = {}) v = context.fetch(identifier) do raise UnboundVariableError.new([identifier]), "no value provided for variables: #{identifier}" end case v when Node v.value(context) when Proc v.call else v end end def dependencies(context = {}) context.key?(identifier) ? dependencies_of(context[identifier]) : [identifier] end private def dependencies_of(node) node.respond_to?(:dependencies) ? node.dependencies : [] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dentaku-3.3.4 | lib/dentaku/ast/identifier.rb |
dentaku-3.3.3 | lib/dentaku/ast/identifier.rb |