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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(left:, right:, location:, comments: []) ⇒ StringConcat
Returns a new instance of StringConcat.
8248 8249 8250 8251 8252 8253 |
# File 'lib/syntax_tree/node.rb', line 8248 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
8246 8247 8248 |
# File 'lib/syntax_tree/node.rb', line 8246 def comments @comments end |
#left ⇒ Object (readonly)
- StringConcat | StringLiteral
-
the left side of the concatenation
8240 8241 8242 |
# File 'lib/syntax_tree/node.rb', line 8240 def left @left end |
#right ⇒ Object (readonly)
- StringLiteral
-
the right side of the concatenation
8243 8244 8245 |
# File 'lib/syntax_tree/node.rb', line 8243 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
8255 8256 8257 |
# File 'lib/syntax_tree/node.rb', line 8255 def accept(visitor) visitor.visit_string_concat(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8259 8260 8261 |
# File 'lib/syntax_tree/node.rb', line 8259 def child_nodes [left, right] end |
#deconstruct_keys(_keys) ⇒ Object
8265 8266 8267 |
# File 'lib/syntax_tree/node.rb', line 8265 def deconstruct_keys(_keys) { left: left, right: right, location: location, comments: comments } end |
#format(q) ⇒ Object
8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 |
# File 'lib/syntax_tree/node.rb', line 8269 def format(q) q.group do q.format(left) q.text(" \\") q.indent do q.breakable(force: true) q.format(right) end end end |