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.
8019 8020 8021 8022 8023 8024 |
# File 'lib/syntax_tree/node.rb', line 8019 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
8017 8018 8019 |
# File 'lib/syntax_tree/node.rb', line 8017 def comments @comments end |
#left ⇒ Object (readonly)
- StringConcat | StringLiteral
-
the left side of the concatenation
8011 8012 8013 |
# File 'lib/syntax_tree/node.rb', line 8011 def left @left end |
#right ⇒ Object (readonly)
- StringLiteral
-
the right side of the concatenation
8014 8015 8016 |
# File 'lib/syntax_tree/node.rb', line 8014 def right @right end |
Instance Method Details
#accept(visitor) ⇒ Object
8026 8027 8028 |
# File 'lib/syntax_tree/node.rb', line 8026 def accept(visitor) visitor.visit_string_concat(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8030 8031 8032 |
# File 'lib/syntax_tree/node.rb', line 8030 def child_nodes [left, right] end |
#deconstruct_keys(keys) ⇒ Object
8036 8037 8038 |
# File 'lib/syntax_tree/node.rb', line 8036 def deconstruct_keys(keys) { left: left, right: right, location: location, comments: comments } end |
#format(q) ⇒ Object
8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 |
# File 'lib/syntax_tree/node.rb', line 8040 def format(q) q.group do q.format(left) q.text(' \\') q.indent do q.breakable(force: true) q.format(right) end end end |