Class: Glyph::SyntaxNode
Overview
A subclass of Glyph::SyntaxNode is instantiated by Glyph::Parser whenever a known text element is parsed.
Direct Known Subclasses
AttributeNode, DocumentNode, EscapeNode, MacroNode, ParameterNode, TextNode
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#evaluate(context, options = {}) ⇒ String
The value of the :value key.
-
#inspect ⇒ String
A textual representation of self.
-
#parent_macro ⇒ Glyph::MacroNode
The first Glyph::MacroNode ancestor.
-
#to_s ⇒ String
An empty string.
Methods inherited from Node
#&, #<<, #==, #>>, #ascend, #child, #clear, #descend, #each_child, #find_child, #find_parent, #from, #initialize, #root, #to_hash, #to_node
Methods inherited from Hash
Constructor Details
This class inherits a constructor from Node
Instance Method Details
#evaluate(context, options = {}) ⇒ String
Returns the value of the :value key.
30 31 32 |
# File 'lib/glyph/syntax_node.rb', line 30 def evaluate(context, ={}) self[:value] end |
#inspect ⇒ String
Returns a textual representation of self.
18 19 20 21 22 23 24 25 26 |
# File 'lib/glyph/syntax_node.rb', line 18 def inspect string = "" descend do |e, level| # Remove document key to avoid endless resursion hash = e.to_hash.reject{|k,v| k == :document} string << " "*level+"(#{e.class})"+hash.inspect+"\n" end string.chomp end |
#parent_macro ⇒ Glyph::MacroNode
Returns the first Glyph::MacroNode ancestor.
36 37 38 |
# File 'lib/glyph/syntax_node.rb', line 36 def parent_macro find_parent{|n| n.is_a?(MacroNode)} end |
#to_s ⇒ String
Returns an empty string.
12 13 14 |
# File 'lib/glyph/syntax_node.rb', line 12 def to_s "" end |