Class: Prism::ClassVariableWriteNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ClassVariableWriteNode
- Defined in:
- lib/prism/node.rb,
lib/prism/parse_result/newlines.rb,
sig/generated/prism/node.rbs,
sig/generated/prism/parse_result/newlines.rbs,
ext/prism/api_node.c
Overview
Class Method Summary collapse
-
.type ⇒ :class_variable_write_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#child_nodes ⇒ Array[node?]
(also: #deconstruct)
See Node.child_nodes.
-
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, value: self.value, operator_loc: self.operator_loc) ⇒ ClassVariableWriteNode
:call-seq: copy(**fields) -> ClassVariableWriteNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#initialize(source, node_id, location, flags, name, name_loc, value, operator_loc) ⇒ ClassVariableWriteNode
constructor
Initialize a new ClassVariableWriteNode node.
-
#inspect ⇒ String
: () -> String.
-
#name ⇒ Symbol
:call-seq: name -> Symbol.
-
#name_loc ⇒ Location
:category: Locations :call-seq: name_loc -> Location.
-
#newline_flag!(lines) ⇒ void
: (Array lines) -> void.
-
#operator ⇒ String
:call-seq: operator -> String.
-
#operator_loc ⇒ Location
:category: Locations :call-seq: operator_loc -> Location.
-
#save_name_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the name_loc location using the given saved source so that it can be retrieved later.
-
#save_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the operator_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ :class_variable_write_node
See
Node#type. -
#value ⇒ Prism::node
:call-seq: value -> Node.
Constructor Details
#initialize(source, node_id, location, flags, name, name_loc, value, operator_loc) ⇒ ClassVariableWriteNode
Initialize a new ClassVariableWriteNode node.
: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value, Location operator_loc) -> void
8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 |
# File 'lib/prism/node.rb', line 8153 def initialize(source, node_id, location, flags, name, name_loc, value, operator_loc) @source = source @node_id = node_id @location = location @flags = flags @name = name @name_loc = name_loc @value = value @operator_loc = operator_loc end |
Class Method Details
.type ⇒ :class_variable_write_node
See Node.type.
: () -> :class_variable_write_node
8245 8246 8247 |
# File 'lib/prism/node.rb', line 8245 def self.type :class_variable_write_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
8367 8368 8369 8370 8371 8372 8373 |
# File 'lib/prism/node.rb', line 8367 def ===(other) # :nodoc: other.is_a?(ClassVariableWriteNode) && (name === other.name) && (name_loc.nil? == other.name_loc.nil?) && (value === other.value) && (operator_loc.nil? == other.operator_loc.nil?) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
8178 8179 8180 |
# File 'lib/prism/node.rb', line 8178 def accept(visitor) visitor.visit_class_variable_write_node(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
8185 8186 8187 |
# File 'lib/prism/node.rb', line 8185 def child_nodes [value] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
8202 8203 8204 |
# File 'lib/prism/node.rb', line 8202 def compact_child_nodes [value] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, value: self.value, operator_loc: self.operator_loc) ⇒ ClassVariableWriteNode
:call-seq:
copy(**fields) -> ClassVariableWriteNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) -> ClassVariableWriteNode
8212 8213 8214 |
# File 'lib/prism/node.rb', line 8212 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, value: self.value, operator_loc: self.operator_loc) ClassVariableWriteNode.new(source, node_id, location, flags, name, name_loc, value, operator_loc) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 |
# File 'lib/prism/node.rb', line 8219 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location name name_loc value operator_loc operator]).each_with_object( {} #: Hash[Symbol, untyped] ) do |key, deconstructed| case key when :node_id then deconstructed[:node_id] = self.node_id when :location then deconstructed[:location] = self.location when :name then deconstructed[:name] = self.name when :name_loc then deconstructed[:name_loc] = self.name_loc when :value then deconstructed[:value] = self.value when :operator_loc then deconstructed[:operator_loc] = self.operator_loc when :operator then deconstructed[:operator] = self.operator end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
8193 8194 8195 8196 8197 |
# File 'lib/prism/node.rb', line 8193 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield value end |
#inspect ⇒ String
: () -> String
8250 8251 8252 |
# File 'lib/prism/node.rb', line 8250 def inspect # :nodoc: InspectVisitor.compose(self) end |
#name ⇒ Symbol
:call-seq:
name -> Symbol
The name of the class variable, which is a @@ followed by an identifier.
@@abc = 123 # name `@@abc`
@@_test = :test # name `@@_test`
: () -> Symbol
8270 8271 8272 |
# File 'lib/prism/node.rb', line 8270 def name @name end |
#name_loc ⇒ Location
:category: Locations :call-seq:
name_loc -> Location
The Location of the variable name.
@@foo = :bar
^^^^^
: () -> Location
8288 8289 8290 8291 8292 |
# File 'lib/prism/node.rb', line 8288 def name_loc location = @name_loc return location if location.is_a?(Location) @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#newline_flag!(lines) ⇒ void
This method returns an undefined value.
: (Array lines) -> void
312 313 314 |
# File 'lib/prism/parse_result/newlines.rb', line 312 def newline_flag!(lines) # :nodoc: value.newline_flag!(lines) end |
#operator ⇒ String
:call-seq:
operator -> String
Slice the location of operator_loc from the source.
: () -> String
8360 8361 8362 |
# File 'lib/prism/node.rb', line 8360 def operator operator_loc.slice end |
#operator_loc ⇒ Location
:category: Locations :call-seq:
operator_loc -> Location
The Location of the = operator.
@@foo = :bar
^
: () -> Location
8337 8338 8339 8340 8341 |
# File 'lib/prism/node.rb', line 8337 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_name_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the name_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
8299 8300 8301 |
# File 'lib/prism/node.rb', line 8299 def save_name_loc(repository) repository.enter(node_id, :name_loc) end |
#save_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the operator_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
8348 8349 8350 |
# File 'lib/prism/node.rb', line 8348 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end |
#type ⇒ :class_variable_write_node
See Node#type.
: () -> :class_variable_write_node
8238 8239 8240 |
# File 'lib/prism/node.rb', line 8238 def type :class_variable_write_node end |
#value ⇒ Prism::node
:call-seq:
value -> Node
The value to write to the class variable. This can be any non-void expression.
@@foo = :bar
^^^^
@@_xyz = 123
^^^
: () -> Prism::node
8319 8320 8321 |
# File 'lib/prism/node.rb', line 8319 def value @value end |