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.
13769 13770 13771 13772 13773 |
# File 'lib/syntax_tree.rb', line 13769 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
13767 13768 13769 |
# File 'lib/syntax_tree.rb', line 13767 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
13764 13765 13766 |
# File 'lib/syntax_tree.rb', line 13764 def location @location end |
#parts ⇒ Object (readonly)
- Array[ StringEmbExpr | StringDVar | TStringContent ]
-
the parts of the
xstring
13761 13762 13763 |
# File 'lib/syntax_tree.rb', line 13761 def parts @parts end |
Instance Method Details
#child_nodes ⇒ Object
13775 13776 13777 |
# File 'lib/syntax_tree.rb', line 13775 def child_nodes parts end |
#format(q) ⇒ Object
13779 13780 13781 13782 13783 |
# File 'lib/syntax_tree.rb', line 13779 def format(q) q.text("`") q.format_each(parts) q.text("`") end |
#pretty_print(q) ⇒ Object
13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 |
# File 'lib/syntax_tree.rb', line 13785 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
13796 13797 13798 13799 13800 13801 13802 13803 |
# File 'lib/syntax_tree.rb', line 13796 def to_json(*opts) { type: :xstring_literal, parts: parts, loc: location, cmts: comments }.to_json(*opts) end |