Class: SyntaxTree::Backtick

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.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

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#pretty_print, #to_json

Constructor Details

#initialize(value:, location:, comments: []) ⇒ Backtick

Returns a new instance of Backtick.



1255
1256
1257
1258
1259
# File 'lib/syntax_tree/node.rb', line 1255

def initialize(value:, location:, comments: [])
  @value = value
  @location = location
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



1253
1254
1255
# File 'lib/syntax_tree/node.rb', line 1253

def comments
  @comments
end

#valueObject (readonly)

String

the backtick in the string



1250
1251
1252
# File 'lib/syntax_tree/node.rb', line 1250

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



1261
1262
1263
# File 'lib/syntax_tree/node.rb', line 1261

def accept(visitor)
  visitor.visit_backtick(self)
end

#child_nodesObject Also known as: deconstruct



1265
1266
1267
# File 'lib/syntax_tree/node.rb', line 1265

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



1271
1272
1273
# File 'lib/syntax_tree/node.rb', line 1271

def deconstruct_keys(keys)
  { value: value, location: location, comments: comments }
end

#format(q) ⇒ Object



1275
1276
1277
# File 'lib/syntax_tree/node.rb', line 1275

def format(q)
  q.text(value)
end