Class: SyntaxTree::TStringContent
Overview
TStringContent represents plain characters inside of an entity that accepts string content like a string, heredoc, command string, or regular expression.
"string"
In the example above, TStringContent represents the string token contained within the string.
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- String
-
the content of the string.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ TStringContent
constructor
A new instance of TStringContent.
- #match?(pattern) ⇒ Boolean
Methods inherited from Node
Constructor Details
#initialize(value:, location:, comments: []) ⇒ TStringContent
Returns a new instance of TStringContent.
8647 8648 8649 8650 8651 |
# File 'lib/syntax_tree/node.rb', line 8647 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8645 8646 8647 |
# File 'lib/syntax_tree/node.rb', line 8645 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the content of the string
8642 8643 8644 |
# File 'lib/syntax_tree/node.rb', line 8642 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
8657 8658 8659 |
# File 'lib/syntax_tree/node.rb', line 8657 def accept(visitor) visitor.visit_tstring_content(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
8661 8662 8663 |
# File 'lib/syntax_tree/node.rb', line 8661 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
8667 8668 8669 |
# File 'lib/syntax_tree/node.rb', line 8667 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
8671 8672 8673 |
# File 'lib/syntax_tree/node.rb', line 8671 def format(q) q.text(value) end |
#match?(pattern) ⇒ Boolean
8653 8654 8655 |
# File 'lib/syntax_tree/node.rb', line 8653 def match?(pattern) value.match?(pattern) end |