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.
5794 5795 5796 5797 5798 |
# File 'lib/syntax_tree/node.rb', line 5794 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
5792 5793 5794 |
# File 'lib/syntax_tree/node.rb', line 5792 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the opening declaration of the heredoc
5789 5790 5791 |
# File 'lib/syntax_tree/node.rb', line 5789 def value @value end |
Instance Method Details
#===(other) ⇒ Object
5829 5830 5831 |
# File 'lib/syntax_tree/node.rb', line 5829 def ===(other) other.is_a?(HeredocBeg) && value === other.value end |
#accept(visitor) ⇒ Object
5800 5801 5802 |
# File 'lib/syntax_tree/node.rb', line 5800 def accept(visitor) visitor.visit_heredoc_beg(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5804 5805 5806 |
# File 'lib/syntax_tree/node.rb', line 5804 def child_nodes [] end |
#copy(value: nil, location: nil) ⇒ Object
5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 |
# File 'lib/syntax_tree/node.rb', line 5808 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
5821 5822 5823 |
# File 'lib/syntax_tree/node.rb', line 5821 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
5825 5826 5827 |
# File 'lib/syntax_tree/node.rb', line 5825 def format(q) q.text(value) end |