Class: SyntaxTree::HeredocEnd
Overview
HeredocEnd represents the closing declaration of a heredoc.
"contents\n"
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.
5848 5849 5850 5851 5852 |
# File 'lib/syntax_tree/node.rb', line 5848 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
5846 5847 5848 |
# File 'lib/syntax_tree/node.rb', line 5846 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the closing declaration of the heredoc
5843 5844 5845 |
# File 'lib/syntax_tree/node.rb', line 5843 def value @value end |
Instance Method Details
#===(other) ⇒ Object
5883 5884 5885 |
# File 'lib/syntax_tree/node.rb', line 5883 def ===(other) other.is_a?(HeredocEnd) && value === other.value end |
#accept(visitor) ⇒ Object
5854 5855 5856 |
# File 'lib/syntax_tree/node.rb', line 5854 def accept(visitor) visitor.visit_heredoc_end(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5858 5859 5860 |
# File 'lib/syntax_tree/node.rb', line 5858 def child_nodes [] end |
#copy(value: nil, location: nil) ⇒ Object
5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 |
# File 'lib/syntax_tree/node.rb', line 5862 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
5875 5876 5877 |
# File 'lib/syntax_tree/node.rb', line 5875 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
5879 5880 5881 |
# File 'lib/syntax_tree/node.rb', line 5879 def format(q) q.text(value) end |