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

#construct_keys, #pretty_print, #to_json

Constructor Details

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

Returns a new instance of Backtick.



1360
1361
1362
1363
1364
# File 'lib/syntax_tree/node.rb', line 1360

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



1358
1359
1360
# File 'lib/syntax_tree/node.rb', line 1358

def comments
  @comments
end

#valueObject (readonly)

String

the backtick in the string



1355
1356
1357
# File 'lib/syntax_tree/node.rb', line 1355

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



1366
1367
1368
# File 'lib/syntax_tree/node.rb', line 1366

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

#child_nodesObject Also known as: deconstruct



1370
1371
1372
# File 'lib/syntax_tree/node.rb', line 1370

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



1376
1377
1378
# File 'lib/syntax_tree/node.rb', line 1376

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

#format(q) ⇒ Object



1380
1381
1382
# File 'lib/syntax_tree/node.rb', line 1380

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