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
1945 1946 1947 1948 1949 |
# File 'lib/syntax_tree.rb', line 1945 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
1943 1944 1945 |
# File 'lib/syntax_tree.rb', line 1943 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1940 1941 1942 |
# File 'lib/syntax_tree.rb', line 1940 def location @location end |
#value ⇒ Object (readonly)
- String
-
the backtick in the string
1937 1938 1939 |
# File 'lib/syntax_tree.rb', line 1937 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
1951 1952 1953 |
# File 'lib/syntax_tree.rb', line 1951 def child_nodes [] end |
#format(q) ⇒ Object
1955 1956 1957 |
# File 'lib/syntax_tree.rb', line 1955 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 |
# File 'lib/syntax_tree.rb', line 1959 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
1970 1971 1972 1973 1974 |
# File 'lib/syntax_tree.rb', line 1970 def to_json(*opts) { type: :backtick, value: value, loc: location, cmts: comments }.to_json( *opts ) end |