Class: Dentaku::AST::Identifier
- Includes:
- StringCasing
- Defined in:
- lib/dentaku/ast/identifier.rb
Instance Attribute Summary collapse
-
#case_sensitive ⇒ Object
readonly
Returns the value of attribute case_sensitive.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #dependencies(context = {}) ⇒ Object
-
#initialize(token, options = {}) ⇒ Identifier
constructor
A new instance of Identifier.
- #to_s ⇒ Object
- #value(context = {}) ⇒ Object
Methods included from StringCasing
Methods inherited from Node
arity, #name, precedence, resolve_class, #type
Constructor Details
#initialize(token, options = {}) ⇒ Identifier
Returns a new instance of Identifier.
10 11 12 13 |
# File 'lib/dentaku/ast/identifier.rb', line 10 def initialize(token, = {}) @case_sensitive = .fetch(:case_sensitive, false) @identifier = standardize_case(token.value) end |
Instance Attribute Details
#case_sensitive ⇒ Object (readonly)
Returns the value of attribute case_sensitive.
8 9 10 |
# File 'lib/dentaku/ast/identifier.rb', line 8 def case_sensitive @case_sensitive end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
8 9 10 |
# File 'lib/dentaku/ast/identifier.rb', line 8 def identifier @identifier end |
Instance Method Details
#accept(visitor) ⇒ Object
37 38 39 |
# File 'lib/dentaku/ast/identifier.rb', line 37 def accept(visitor) visitor.visit_identifier(self) end |
#dependencies(context = {}) ⇒ Object
33 34 35 |
# File 'lib/dentaku/ast/identifier.rb', line 33 def dependencies(context = {}) context.key?(identifier) ? dependencies_of(context[identifier], context) : [identifier] end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/dentaku/ast/identifier.rb', line 41 def to_s identifier.to_s end |
#value(context = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dentaku/ast/identifier.rb', line 15 def value(context = {}) v = context.fetch(identifier) do raise UnboundVariableError.new([identifier]), "no value provided for variables: #{identifier}" end case v when Node value = v.value(context) context[identifier] = value if Dentaku.cache_identifier? value when Proc v.call else v end end |