Class: SyntaxTree::HeredocBeg
Overview
HeredocBeg represents the beginning declaration of a heredoc.
<<~DOC
contents
DOC
In the example above the HeredocBeg node represents <<~DOC.
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- String
-
the opening 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:) ⇒ HeredocBeg
constructor
A new instance of HeredocBeg.
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, location:) ⇒ HeredocBeg
Returns a new instance of HeredocBeg.
5908 5909 5910 5911 5912 |
# File 'lib/syntax_tree/node.rb', line 5908 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
5906 5907 5908 |
# File 'lib/syntax_tree/node.rb', line 5906 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the opening declaration of the heredoc
5903 5904 5905 |
# File 'lib/syntax_tree/node.rb', line 5903 def value @value end |
Instance Method Details
#===(other) ⇒ Object
5943 5944 5945 |
# File 'lib/syntax_tree/node.rb', line 5943 def ===(other) other.is_a?(HeredocBeg) && value === other.value end |
#accept(visitor) ⇒ Object
5914 5915 5916 |
# File 'lib/syntax_tree/node.rb', line 5914 def accept(visitor) visitor.visit_heredoc_beg(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5918 5919 5920 |
# File 'lib/syntax_tree/node.rb', line 5918 def child_nodes [] end |
#copy(value: nil, location: nil) ⇒ Object
5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 |
# File 'lib/syntax_tree/node.rb', line 5922 def copy(value: nil, location: nil) node = HeredocBeg.new( value: value || self.value, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end |
#deconstruct_keys(_keys) ⇒ Object
5935 5936 5937 |
# File 'lib/syntax_tree/node.rb', line 5935 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
5939 5940 5941 |
# File 'lib/syntax_tree/node.rb', line 5939 def format(q) q.text(value) end |