Class: SyntaxTree::HeredocBeg
- Inherits:
-
Object
- Object
- SyntaxTree::HeredocBeg
- Defined in:
- lib/syntax_tree.rb
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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#value ⇒ Object
readonly
- String
-
the opening declaration of the heredoc.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ HeredocBeg
constructor
A new instance of HeredocBeg.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ HeredocBeg
Returns a new instance of HeredocBeg.
6500 6501 6502 6503 6504 |
# File 'lib/syntax_tree.rb', line 6500 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
6498 6499 6500 |
# File 'lib/syntax_tree.rb', line 6498 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
6495 6496 6497 |
# File 'lib/syntax_tree.rb', line 6495 def location @location end |
#value ⇒ Object (readonly)
- String
-
the opening declaration of the heredoc
6492 6493 6494 |
# File 'lib/syntax_tree.rb', line 6492 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
6506 6507 6508 |
# File 'lib/syntax_tree.rb', line 6506 def child_nodes [] end |
#format(q) ⇒ Object
6510 6511 6512 |
# File 'lib/syntax_tree.rb', line 6510 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 |
# File 'lib/syntax_tree.rb', line 6514 def pretty_print(q) q.group(2, "(", ")") do q.text("heredoc_beg") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
6525 6526 6527 6528 6529 6530 6531 6532 |
# File 'lib/syntax_tree.rb', line 6525 def to_json(*opts) { type: :heredoc_beg, value: value, loc: location, cmts: comments }.to_json(*opts) end |