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
Returns a new instance of Backtick.
2085 2086 2087 2088 2089 |
# File 'lib/syntax_tree.rb', line 2085 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
2083 2084 2085 |
# File 'lib/syntax_tree.rb', line 2083 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
2080 2081 2082 |
# File 'lib/syntax_tree.rb', line 2080 def location @location end |
#value ⇒ Object (readonly)
- String
-
the backtick in the string
2077 2078 2079 |
# File 'lib/syntax_tree.rb', line 2077 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
2091 2092 2093 |
# File 'lib/syntax_tree.rb', line 2091 def child_nodes [] end |
#format(q) ⇒ Object
2095 2096 2097 |
# File 'lib/syntax_tree.rb', line 2095 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 |
# File 'lib/syntax_tree.rb', line 2099 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
2110 2111 2112 2113 2114 |
# File 'lib/syntax_tree.rb', line 2110 def to_json(*opts) { type: :backtick, value: value, loc: location, cmts: comments }.to_json( *opts ) end |