Class: SyntaxTree::XStringLiteral
- Inherits:
-
Object
- Object
- SyntaxTree::XStringLiteral
- Defined in:
- lib/syntax_tree.rb
Overview
XStringLiteral represents a string that gets executed.
`ls`
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#parts ⇒ Object
readonly
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the xstring.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(parts:, location:, comments: []) ⇒ XStringLiteral
constructor
A new instance of XStringLiteral.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(parts:, location:, comments: []) ⇒ XStringLiteral
Returns a new instance of XStringLiteral.
13565 13566 13567 13568 13569 |
# File 'lib/syntax_tree.rb', line 13565 def initialize(parts:, location:, comments: []) @parts = parts @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
13563 13564 13565 |
# File 'lib/syntax_tree.rb', line 13563 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
13560 13561 13562 |
# File 'lib/syntax_tree.rb', line 13560 def location @location end |
#parts ⇒ Object (readonly)
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the
xstring
13557 13558 13559 |
# File 'lib/syntax_tree.rb', line 13557 def parts @parts end |
Instance Method Details
#child_nodes ⇒ Object
13571 13572 13573 |
# File 'lib/syntax_tree.rb', line 13571 def child_nodes parts end |
#format(q) ⇒ Object
13575 13576 13577 13578 13579 |
# File 'lib/syntax_tree.rb', line 13575 def format(q) q.text("`") q.format_each(parts) q.text("`") end |
#pretty_print(q) ⇒ Object
13581 13582 13583 13584 13585 13586 13587 13588 13589 13590 |
# File 'lib/syntax_tree.rb', line 13581 def pretty_print(q) q.group(2, "(", ")") do q.text("xstring_literal") q.breakable q.group(2, "(", ")") { q.seplist(parts) { |part| q.pp(part) } } q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
13592 13593 13594 13595 13596 13597 13598 13599 |
# File 'lib/syntax_tree.rb', line 13592 def to_json(*opts) { type: :xstring_literal, parts: parts, loc: location, cmts: comments }.to_json(*opts) end |