Class: Prism::InstanceVariableTargetNode

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

Overview

Represents writing to an instance variable in a context that doesn’t have an explicit value.

@foo, @bar = baz
^^^^  ^^^^

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, name) ⇒ InstanceVariableTargetNode

Initialize a new InstanceVariableTargetNode node.



10931
10932
10933
10934
10935
10936
10937
# File 'lib/prism/node.rb', line 10931

def initialize(source, node_id, location, flags, name)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

attr_reader name: Symbol



10979
10980
10981
# File 'lib/prism/node.rb', line 10979

def name
  @name
end

Class Method Details

.typeObject

Return a symbol representation of this node type. See Node::type.



10992
10993
10994
# File 'lib/prism/node.rb', line 10992

def self.type
  :instance_variable_target_node
end

Instance Method Details

#===(other) ⇒ Object

Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.



10998
10999
11000
11001
# File 'lib/prism/node.rb', line 10998

def ===(other)
  other.is_a?(InstanceVariableTargetNode) &&
    (name === other.name)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



10940
10941
10942
# File 'lib/prism/node.rb', line 10940

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



10945
10946
10947
# File 'lib/prism/node.rb', line 10945

def child_nodes
  []
end

#comment_targetsObject

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



10961
10962
10963
# File 'lib/prism/node.rb', line 10961

def comment_targets
  [] #: Array[Prism::node | Location]
end

#compact_child_nodesObject

def compact_child_nodes: () -> Array



10956
10957
10958
# File 'lib/prism/node.rb', line 10956

def compact_child_nodes
  []
end

#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name) ⇒ Object

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol) -> InstanceVariableTargetNode



10966
10967
10968
# File 'lib/prism/node.rb', line 10966

def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name)
  InstanceVariableTargetNode.new(source, node_id, location, flags, name)
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol }



10974
10975
10976
# File 'lib/prism/node.rb', line 10974

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

#each_child_nodeObject

def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator



10950
10951
10952
10953
# File 'lib/prism/node.rb', line 10950

def each_child_node
  return to_enum(:each_child_node) unless block_given?

end

#inspectObject

def inspect -> String



10982
10983
10984
# File 'lib/prism/node.rb', line 10982

def inspect
  InspectVisitor.compose(self)
end

#typeObject

Return a symbol representation of this node type. See ‘Node#type`.



10987
10988
10989
# File 'lib/prism/node.rb', line 10987

def type
  :instance_variable_target_node
end