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, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ HeredocEnd
Returns a new instance of HeredocEnd.
5839 5840 5841 5842 5843 |
# File 'lib/syntax_tree/node.rb', line 5839 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
5837 5838 5839 |
# File 'lib/syntax_tree/node.rb', line 5837 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the closing declaration of the heredoc
5834 5835 5836 |
# File 'lib/syntax_tree/node.rb', line 5834 def value @value end |
Instance Method Details
#===(other) ⇒ Object
5874 5875 5876 |
# File 'lib/syntax_tree/node.rb', line 5874 def ===(other) other.is_a?(HeredocEnd) && value === other.value end |
#accept(visitor) ⇒ Object
5845 5846 5847 |
# File 'lib/syntax_tree/node.rb', line 5845 def accept(visitor) visitor.visit_heredoc_end(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5849 5850 5851 |
# File 'lib/syntax_tree/node.rb', line 5849 def child_nodes [] end |
#copy(value: nil, location: nil) ⇒ Object
5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 |
# File 'lib/syntax_tree/node.rb', line 5853 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
5866 5867 5868 |
# File 'lib/syntax_tree/node.rb', line 5866 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
5870 5871 5872 |
# File 'lib/syntax_tree/node.rb', line 5870 def format(q) q.text(value) end |