Class: Glyph::AttributeNode
- Inherits:
-
SyntaxNode
- Object
- Hash
- Node
- SyntaxNode
- Glyph::AttributeNode
- Defined in:
- lib/glyph/syntax_node.rb
Overview
A Glyph macro attribute in Glyph Abstract Syntax Tree
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#contents ⇒ String
A textual representation of the attribute contents.
-
#evaluate(context, options = {:attrs => false}) ⇒ String
The evaluated child nodes.
-
#to_s ⇒ String
A textual representation of the attribute node.
Methods inherited from SyntaxNode
Methods inherited from Node
#&, #<<, #==, #>>, #ascend, #child, #clear, #descend, #each_child, #find_child, #find_parent, #from, #initialize, #inspect, #root, #to_hash, #to_node
Methods inherited from Hash
Constructor Details
This class inherits a constructor from Node
Instance Method Details
#contents ⇒ String
Returns a textual representation of the attribute contents.
219 220 221 |
# File 'lib/glyph/syntax_node.rb', line 219 def contents self[:escape] ? ".[=#{children.join}=]" : children.join end |
#evaluate(context, options = {:attrs => false}) ⇒ String
Returns the evaluated child nodes.
228 229 230 231 232 |
# File 'lib/glyph/syntax_node.rb', line 228 def evaluate(context, ={:attrs => false}) self[:value] = "" self.children.each {|c| self[:value] << c.evaluate(context) } if [:attrs] self[:value] end |
#to_s ⇒ String
Returns a textual representation of the attribute node.
212 213 214 215 |
# File 'lib/glyph/syntax_node.rb', line 212 def to_s e = self[:escape] ? "=" : "" "@#{self[:name]}["+e+children.join+e+"]" end |