Class: SyntaxTree::ZSuper

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

ZSuper represents the bare super keyword with no arguments.

super

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(location:) ⇒ ZSuper

Returns a new instance of ZSuper.



12169
12170
12171
12172
# File 'lib/syntax_tree/node.rb', line 12169

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



12167
12168
12169
# File 'lib/syntax_tree/node.rb', line 12167

def comments
  @comments
end

Instance Method Details

#===(other) ⇒ Object



12199
12200
12201
# File 'lib/syntax_tree/node.rb', line 12199

def ===(other)
  other.is_a?(ZSuper)
end

#accept(visitor) ⇒ Object



12174
12175
12176
# File 'lib/syntax_tree/node.rb', line 12174

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

#child_nodesObject Also known as: deconstruct



12178
12179
12180
# File 'lib/syntax_tree/node.rb', line 12178

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



12182
12183
12184
12185
12186
12187
# File 'lib/syntax_tree/node.rb', line 12182

def copy(location: nil)
  node = ZSuper.new(location: location || self.location)

  node.comments.concat(comments.map(&:copy))
  node
end

#deconstruct_keys(_keys) ⇒ Object



12191
12192
12193
# File 'lib/syntax_tree/node.rb', line 12191

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

#format(q) ⇒ Object



12195
12196
12197
# File 'lib/syntax_tree/node.rb', line 12195

def format(q)
  q.text("super")
end