Class: SyntaxTree::ERB::Element
- Defined in:
- lib/syntax_tree/erb/nodes.rb
Overview
This is a base class for a Node that can also hold an appended new line.
Direct Known Subclasses
CharData, Doctype, ErbClose, ErbComment, ErbNode, HtmlComment, HtmlNode::ClosingTag, HtmlNode::OpeningTag
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#new_line ⇒ Object
readonly
Returns the value of attribute new_line.
Instance Method Summary collapse
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(new_line:, location:) ⇒ Element
constructor
A new instance of Element.
- #without_new_line ⇒ Object
Methods inherited from Node
#format, #pretty_print, #skip?
Constructor Details
#initialize(new_line:, location:) ⇒ Element
Returns a new instance of Element.
126 127 128 129 |
# File 'lib/syntax_tree/erb/nodes.rb', line 126 def initialize(new_line:, location:) @new_line = new_line @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
124 125 126 |
# File 'lib/syntax_tree/erb/nodes.rb', line 124 def location @location end |
#new_line ⇒ Object (readonly)
Returns the value of attribute new_line.
124 125 126 |
# File 'lib/syntax_tree/erb/nodes.rb', line 124 def new_line @new_line end |
Instance Method Details
#deconstruct_keys(keys) ⇒ Object
135 136 137 |
# File 'lib/syntax_tree/erb/nodes.rb', line 135 def deconstruct_keys(keys) { new_line: new_line, location: location } end |
#without_new_line ⇒ Object
131 132 133 |
# File 'lib/syntax_tree/erb/nodes.rb', line 131 def without_new_line self.class.new(**deconstruct_keys([]).merge(new_line: nil)) end |