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, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ HeredocBeg
Returns a new instance of HeredocBeg.
5785 5786 5787 5788 5789 |
# File 'lib/syntax_tree/node.rb', line 5785 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
5783 5784 5785 |
# File 'lib/syntax_tree/node.rb', line 5783 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the opening declaration of the heredoc
5780 5781 5782 |
# File 'lib/syntax_tree/node.rb', line 5780 def value @value end |
Instance Method Details
#===(other) ⇒ Object
5820 5821 5822 |
# File 'lib/syntax_tree/node.rb', line 5820 def ===(other) other.is_a?(HeredocBeg) && value === other.value end |
#accept(visitor) ⇒ Object
5791 5792 5793 |
# File 'lib/syntax_tree/node.rb', line 5791 def accept(visitor) visitor.visit_heredoc_beg(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
5795 5796 5797 |
# File 'lib/syntax_tree/node.rb', line 5795 def child_nodes [] end |
#copy(value: nil, location: nil) ⇒ Object
5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 |
# File 'lib/syntax_tree/node.rb', line 5799 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
5812 5813 5814 |
# File 'lib/syntax_tree/node.rb', line 5812 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
5816 5817 5818 |
# File 'lib/syntax_tree/node.rb', line 5816 def format(q) q.text(value) end |