Class: SyntaxTree::StringConcat
Overview
StringConcat represents concatenating two strings together using a backward slash.
"first" \
"second"
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#left ⇒ Object
readonly
- StringConcat | StringLiteral
-
the left side of the concatenation.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#right ⇒ Object
readonly
- StringLiteral
-
the right side of the concatenation.
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(left:, right:, location:, comments: []) ⇒ StringConcat
constructor
A new instance of StringConcat.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(left:, right:, location:, comments: []) ⇒ StringConcat
Returns a new instance of StringConcat.
9561 9562 9563 9564 9565 9566 |
# File 'lib/syntax_tree/node.rb', line 9561 def initialize(left:, right:, location:, comments: []) @left = left @right = right @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
9559 9560 9561 |
# File 'lib/syntax_tree/node.rb', line 9559 def comments @comments end |
#left ⇒ Object (readonly)
- StringConcat | StringLiteral
-
the left side of the concatenation
9550 9551 9552 |
# File 'lib/syntax_tree/node.rb', line 9550 def left @left end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
9556 9557 9558 |
# File 'lib/syntax_tree/node.rb', line 9556 def location @location end |
#right ⇒ Object (readonly)
- StringLiteral
-
the right side of the concatenation
9553 9554 9555 |
# File 'lib/syntax_tree/node.rb', line 9553 def right @right end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
9568 9569 9570 |
# File 'lib/syntax_tree/node.rb', line 9568 def child_nodes [left, right] end |
#deconstruct_keys(keys) ⇒ Object
9574 9575 9576 |
# File 'lib/syntax_tree/node.rb', line 9574 def deconstruct_keys(keys) { left: left, right: right, location: location, comments: comments } end |
#format(q) ⇒ Object
9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 |
# File 'lib/syntax_tree/node.rb', line 9578 def format(q) q.group do q.format(left) q.text(' \\') q.indent do q.breakable(force: true) q.format(right) end end end |
#pretty_print(q) ⇒ Object
9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 |
# File 'lib/syntax_tree/node.rb', line 9589 def pretty_print(q) q.group(2, "(", ")") do q.text("string_concat") q.breakable q.pp(left) q.breakable q.pp(right) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
9603 9604 9605 9606 9607 9608 9609 9610 9611 |
# File 'lib/syntax_tree/node.rb', line 9603 def to_json(*opts) { type: :string_concat, left: left, right: right, loc: location, cmts: comments }.to_json(*opts) end |