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.
-
#right ⇒ Object
readonly
- StringLiteral
-
the right side of the concatenation.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(left:, right:, location:, comments: []) ⇒ StringConcat
constructor
A new instance of StringConcat.
Methods inherited from Node
Constructor Details
#initialize(left:, right:, location:, comments: []) ⇒ StringConcat
Returns a new instance of StringConcat.
7476 7477 7478 7479 7480 7481 |
# File 'lib/syntax_tree/node.rb', line 7476 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
7474 7475 7476 |
# File 'lib/syntax_tree/node.rb', line 7474 def comments @comments end |
#left ⇒ Object (readonly)
- StringConcat | StringLiteral
-
the left side of the concatenation
7468 7469 7470 |
# File 'lib/syntax_tree/node.rb', line 7468 def left @left end |
#right ⇒ Object (readonly)
- StringLiteral
-
the right side of the concatenation
7471 7472 7473 |
# File 'lib/syntax_tree/node.rb', line 7471 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
7483 7484 7485 |
# File 'lib/syntax_tree/node.rb', line 7483 def accept(visitor) visitor.visit_string_concat(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
7487 7488 7489 |
# File 'lib/syntax_tree/node.rb', line 7487 def child_nodes [left, right] end |
#deconstruct_keys(keys) ⇒ Object
7493 7494 7495 |
# File 'lib/syntax_tree/node.rb', line 7493 def deconstruct_keys(keys) { left: left, right: right, location: location, comments: comments } end |
#format(q) ⇒ Object
7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 |
# File 'lib/syntax_tree/node.rb', line 7497 def format(q) q.group do q.format(left) q.text(' \\') q.indent do q.breakable(force: true) q.format(right) end end end |