Class: SyntaxTree::ERB::Block
Overview
This is a base class for a block that contains:
-
an opening
-
optional elements
-
optional closing
Direct Known Subclasses
Instance Attribute Summary collapse
-
#closing ⇒ Object
readonly
Returns the value of attribute closing.
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#opening ⇒ Object
readonly
Returns the value of attribute opening.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(opening:, location:, elements: nil, closing: nil) ⇒ Block
constructor
A new instance of Block.
Methods inherited from Node
Constructor Details
#initialize(opening:, location:, elements: nil, closing: nil) ⇒ Block
Returns a new instance of Block.
119 120 121 122 123 124 |
# File 'lib/syntax_tree/erb/nodes.rb', line 119 def initialize(opening:, location:, elements: nil, closing: nil) @opening = opening @elements = elements || [] @closing = closing @location = location end |
Instance Attribute Details
#closing ⇒ Object (readonly)
Returns the value of attribute closing.
118 119 120 |
# File 'lib/syntax_tree/erb/nodes.rb', line 118 def closing @closing end |
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
118 119 120 |
# File 'lib/syntax_tree/erb/nodes.rb', line 118 def elements @elements end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
118 119 120 |
# File 'lib/syntax_tree/erb/nodes.rb', line 118 def location @location end |
#opening ⇒ Object (readonly)
Returns the value of attribute opening.
118 119 120 |
# File 'lib/syntax_tree/erb/nodes.rb', line 118 def opening @opening end |
Instance Method Details
#accept(visitor) ⇒ Object
126 127 128 |
# File 'lib/syntax_tree/erb/nodes.rb', line 126 def accept(visitor) visitor.visit_block(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
130 131 132 |
# File 'lib/syntax_tree/erb/nodes.rb', line 130 def child_nodes [opening, *elements, closing].compact end |
#deconstruct_keys(keys) ⇒ Object
136 137 138 139 140 141 142 143 |
# File 'lib/syntax_tree/erb/nodes.rb', line 136 def deconstruct_keys(keys) { opening: opening, content: content, closing: closing, location: location } end |