Class: YARP::ConstantReadNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

Represents referencing a constant.

Foo
^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, location) ⇒ ConstantReadNode

def initialize: (name: Symbol, location: Location) -> void



3225
3226
3227
3228
# File 'lib/yarp/node.rb', line 3225

def initialize(name, location)
  @name = name
  @location = location
end

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



3222
3223
3224
# File 'lib/yarp/node.rb', line 3222

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



3231
3232
3233
# File 'lib/yarp/node.rb', line 3231

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



3236
3237
3238
# File 'lib/yarp/node.rb', line 3236

def child_nodes
  []
end

#comment_targetsObject

def comment_targets: () -> Array[Node | Location]



3241
3242
3243
# File 'lib/yarp/node.rb', line 3241

def comment_targets
  []
end

#copy(**params) ⇒ Object

def copy: (**params) -> ConstantReadNode



3246
3247
3248
3249
3250
3251
# File 'lib/yarp/node.rb', line 3246

def copy(**params)
  ConstantReadNode.new(
    params.fetch(:name) { name },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



3257
3258
3259
# File 'lib/yarp/node.rb', line 3257

def deconstruct_keys(keys)
  { name: name, location: location }
end

#inspect(inspector = NodeInspector.new) ⇒ Object



3261
3262
3263
3264
3265
# File 'lib/yarp/node.rb', line 3261

def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  inspector << "└── name: #{name.inspect}\n"
  inspector.to_str
end