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
2055 2056 2057 2058 2059 |
# File 'lib/syntax_tree.rb', line 2055 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
2053 2054 2055 |
# File 'lib/syntax_tree.rb', line 2053 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
2050 2051 2052 |
# File 'lib/syntax_tree.rb', line 2050 def location @location end |
#value ⇒ Object (readonly)
- String
-
the backtick in the string
2047 2048 2049 |
# File 'lib/syntax_tree.rb', line 2047 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
2061 2062 2063 |
# File 'lib/syntax_tree.rb', line 2061 def child_nodes [] end |
#format(q) ⇒ Object
2065 2066 2067 |
# File 'lib/syntax_tree.rb', line 2065 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 |
# File 'lib/syntax_tree.rb', line 2069 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
2080 2081 2082 2083 2084 |
# File 'lib/syntax_tree.rb', line 2080 def to_json(*opts) { type: :backtick, value: value, loc: location, cmts: comments }.to_json( *opts ) end |