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.



84
85
86
87
# File 'lib/syntax_tree/erb/nodes.rb', line 84

def initialize(new_line:, location:)
  @new_line = new_line
  @location = location
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



82
83
84
# File 'lib/syntax_tree/erb/nodes.rb', line 82

def location
  @location
end

#new_lineObject (readonly)

Returns the value of attribute new_line.



82
83
84
# File 'lib/syntax_tree/erb/nodes.rb', line 82

def new_line
  @new_line
end

Instance Method Details

#deconstruct_keys(keys) ⇒ Object



93
94
95
# File 'lib/syntax_tree/erb/nodes.rb', line 93

def deconstruct_keys(keys)
  { new_line: new_line, location: location }
end

#without_new_lineObject



89
90
91
# File 'lib/syntax_tree/erb/nodes.rb', line 89

def without_new_line
  self.class.new(**deconstruct_keys([]).merge(new_line: nil))
end