Class: SyntaxTree::ERB::Element

Inherits:
Node
  • Object
show all
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.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#locationObject (readonly)

Returns the value of attribute location.



124
125
126
# File 'lib/syntax_tree/erb/nodes.rb', line 124

def location
  @location
end

#new_lineObject (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_lineObject



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