Class: SyntaxTree::Backtick
Overview
Backtick represents the use of the ‘ operator. It’s usually found being used for an XStringLiteral, but could also be found as the name of a method being defined.
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.
-
#value ⇒ Object
readonly
- String
-
the backtick in the string.
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ Backtick
constructor
A new instance of Backtick.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ Backtick
Returns a new instance of Backtick.
1616 1617 1618 1619 1620 |
# File 'lib/syntax_tree/node.rb', line 1616 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
1614 1615 1616 |
# File 'lib/syntax_tree/node.rb', line 1614 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1611 1612 1613 |
# File 'lib/syntax_tree/node.rb', line 1611 def location @location end |
#value ⇒ Object (readonly)
- String
-
the backtick in the string
1608 1609 1610 |
# File 'lib/syntax_tree/node.rb', line 1608 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
1622 1623 1624 |
# File 'lib/syntax_tree/node.rb', line 1622 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
1628 1629 1630 |
# File 'lib/syntax_tree/node.rb', line 1628 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
1632 1633 1634 |
# File 'lib/syntax_tree/node.rb', line 1632 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 |
# File 'lib/syntax_tree/node.rb', line 1636 def pretty_print(q) q.group(2, "(", ")") do q.text("backtick") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
1647 1648 1649 1650 1651 |
# File 'lib/syntax_tree/node.rb', line 1647 def to_json(*opts) { type: :backtick, value: value, loc: location, cmts: comments }.to_json( *opts ) end |