Class: SyntaxTree::Backtick
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::Backtick
show all
- Defined in:
- lib/syntax_tree/node.rb
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
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, location:) ⇒ Backtick
Returns a new instance of Backtick.
1685
1686
1687
1688
1689
|
# File 'lib/syntax_tree/node.rb', line 1685
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
1683
1684
1685
|
# File 'lib/syntax_tree/node.rb', line 1683
def
@comments
end
|
#value ⇒ Object
- String
-
the backtick in the string
1680
1681
1682
|
# File 'lib/syntax_tree/node.rb', line 1680
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
1720
1721
1722
|
# File 'lib/syntax_tree/node.rb', line 1720
def ===(other)
other.is_a?(Backtick) && value === other.value
end
|
#accept(visitor) ⇒ Object
1691
1692
1693
|
# File 'lib/syntax_tree/node.rb', line 1691
def accept(visitor)
visitor.visit_backtick(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
1695
1696
1697
|
# File 'lib/syntax_tree/node.rb', line 1695
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
|
# File 'lib/syntax_tree/node.rb', line 1699
def copy(value: nil, location: nil)
node =
Backtick.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
1712
1713
1714
|
# File 'lib/syntax_tree/node.rb', line 1712
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
1716
1717
1718
|
# File 'lib/syntax_tree/node.rb', line 1716
def format(q)
q.text(value)
end
|