Class: SyntaxTree::StringConcat
- Inherits:
-
Object
- Object
- SyntaxTree::StringConcat
- Defined in:
- lib/syntax_tree.rb
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
- #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.
10991 10992 10993 10994 10995 10996 |
# File 'lib/syntax_tree.rb', line 10991 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
10989 10990 10991 |
# File 'lib/syntax_tree.rb', line 10989 def comments @comments end |
#left ⇒ Object (readonly)
- StringConcat | StringLiteral
-
the left side of the concatenation
10980 10981 10982 |
# File 'lib/syntax_tree.rb', line 10980 def left @left end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
10986 10987 10988 |
# File 'lib/syntax_tree.rb', line 10986 def location @location end |
#right ⇒ Object (readonly)
- StringLiteral
-
the right side of the concatenation
10983 10984 10985 |
# File 'lib/syntax_tree.rb', line 10983 def right @right end |
Instance Method Details
#child_nodes ⇒ Object
10998 10999 11000 |
# File 'lib/syntax_tree.rb', line 10998 def child_nodes [left, right] end |
#format(q) ⇒ Object
11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 |
# File 'lib/syntax_tree.rb', line 11002 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
11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 |
# File 'lib/syntax_tree.rb', line 11013 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
11027 11028 11029 11030 11031 11032 11033 11034 11035 |
# File 'lib/syntax_tree.rb', line 11027 def to_json(*opts) { type: :string_concat, left: left, right: right, loc: location, cmts: comments }.to_json(*opts) end |