Class: SyntaxTree::Backtick
- Inherits:
-
Object
- Object
- SyntaxTree::Backtick
- Defined in:
- lib/syntax_tree.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
-
#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
- #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
2113 2114 2115 2116 2117 |
# File 'lib/syntax_tree.rb', line 2113 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
2111 2112 2113 |
# File 'lib/syntax_tree.rb', line 2111 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
2108 2109 2110 |
# File 'lib/syntax_tree.rb', line 2108 def location @location end |
#value ⇒ Object (readonly)
- String
-
the backtick in the string
2105 2106 2107 |
# File 'lib/syntax_tree.rb', line 2105 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
2119 2120 2121 |
# File 'lib/syntax_tree.rb', line 2119 def child_nodes [] end |
#format(q) ⇒ Object
2123 2124 2125 |
# File 'lib/syntax_tree.rb', line 2123 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 |
# File 'lib/syntax_tree.rb', line 2127 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
2138 2139 2140 2141 2142 |
# File 'lib/syntax_tree.rb', line 2138 def to_json(*opts) { type: :backtick, value: value, loc: location, cmts: comments }.to_json( *opts ) end |