Class: SyntaxTree::HeredocBeg
Overview
HeredocBeg represents the beginning declaration of a heredoc.
"contents\n"
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, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ HeredocBeg
Returns a new instance of HeredocBeg.
5780 5781 5782 5783 5784 |
# File 'lib/syntax_tree/node.rb', line 5780 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
5778 5779 5780 |
# File 'lib/syntax_tree/node.rb', line 5778 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the opening declaration of the heredoc
5775 5776 5777 |
# File 'lib/syntax_tree/node.rb', line 5775 def value @value end |
Instance Method Details
#===(other) ⇒ Object
5815 5816 5817 |
# File 'lib/syntax_tree/node.rb', line 5815 def ===(other) other.is_a?(HeredocBeg) && value === other.value end |
#accept(visitor) ⇒ Object
5786 5787 5788 |
# File 'lib/syntax_tree/node.rb', line 5786 def accept(visitor) visitor.visit_heredoc_beg(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5790 5791 5792 |
# File 'lib/syntax_tree/node.rb', line 5790 def child_nodes [] end |
#copy(value: nil, location: nil) ⇒ Object
5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 |
# File 'lib/syntax_tree/node.rb', line 5794 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
5807 5808 5809 |
# File 'lib/syntax_tree/node.rb', line 5807 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
5811 5812 5813 |
# File 'lib/syntax_tree/node.rb', line 5811 def format(q) q.text(value) end |