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.
-
#value ⇒ Object
readonly
- String
-
the backtick in the string.
Attributes inherited from Node
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.
1562 1563 1564 1565 1566 |
# File 'lib/syntax_tree/node.rb', line 1562 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
1560 1561 1562 |
# File 'lib/syntax_tree/node.rb', line 1560 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the backtick in the string
1557 1558 1559 |
# File 'lib/syntax_tree/node.rb', line 1557 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
1568 1569 1570 |
# File 'lib/syntax_tree/node.rb', line 1568 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
1574 1575 1576 |
# File 'lib/syntax_tree/node.rb', line 1574 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
1578 1579 1580 |
# File 'lib/syntax_tree/node.rb', line 1578 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 |
# File 'lib/syntax_tree/node.rb', line 1582 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
1593 1594 1595 1596 1597 |
# File 'lib/syntax_tree/node.rb', line 1593 def to_json(*opts) { type: :backtick, value: value, loc: location, cmts: comments }.to_json( *opts ) end |