Class: SyntaxTree::HeredocEnd
Overview
HeredocEnd represents the closing declaration of a heredoc.
<<~DOC
contents
DOC
In the example above the HeredocEnd node represents the closing DOC.
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- String
-
the closing declaration of the heredoc.
Attributes inherited from Node
Instance Method Summary collapse
- #===(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #copy(value: nil, location: nil) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:) ⇒ HeredocEnd
constructor
A new instance of HeredocEnd.
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, location:) ⇒ HeredocEnd
Returns a new instance of HeredocEnd.
5947 5948 5949 5950 5951 |
# File 'lib/syntax_tree/node.rb', line 5947 def initialize(value:, location:) @value = value @location = location @comments = [] end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5945 5946 5947 |
# File 'lib/syntax_tree/node.rb', line 5945 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the closing declaration of the heredoc
5942 5943 5944 |
# File 'lib/syntax_tree/node.rb', line 5942 def value @value end |
Instance Method Details
#===(other) ⇒ Object
5982 5983 5984 |
# File 'lib/syntax_tree/node.rb', line 5982 def ===(other) other.is_a?(HeredocEnd) && value === other.value end |
#accept(visitor) ⇒ Object
5953 5954 5955 |
# File 'lib/syntax_tree/node.rb', line 5953 def accept(visitor) visitor.visit_heredoc_end(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5957 5958 5959 |
# File 'lib/syntax_tree/node.rb', line 5957 def child_nodes [] end |
#copy(value: nil, location: nil) ⇒ Object
5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 |
# File 'lib/syntax_tree/node.rb', line 5961 def copy(value: nil, location: nil) node = HeredocEnd.new( value: value || self.value, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end |
#deconstruct_keys(_keys) ⇒ Object
5974 5975 5976 |
# File 'lib/syntax_tree/node.rb', line 5974 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
5978 5979 5980 |
# File 'lib/syntax_tree/node.rb', line 5978 def format(q) q.text(value) end |