class Prism::ConstantWriteNode
Represents writing to a constant.
Foo = 1 ^^^^^^^
Represents writing to a constant.
Foo = 1 ^^^^^^^
Public Class Methods
(Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value, Location operator_loc) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10506 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
Initialize a new ConstantWriteNode node.
Initialize a new ConstantWriteNode node.
: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Prism::node value, Location operator_loc) -> void
Public Instance Methods
(untyped other) → boolish
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 6988
def ===: (untyped other) -> boolish
: (untyped other) -> boolish
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 6884
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
() → String
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node_ext.rb, line 210 def full_name name.to_s end
Returns the full name of this constant. For example: “Foo”
Returns the full name of this constant. For example: “Foo”
: () -> String
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node_ext.rb, line 203 def full_name_parts [name] end
Returns the list of parts for the full name of this constant. For example: [:Foo]
Returns the list of parts for the full name of this constant. For example: [:Foo]
: () -> Array
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 6897
def inspect: () -> String
: () -> String
() → Symbol
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10623 def name @name end
(Array[bool] lines) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/parse_result/newlines.rbs, line 171
def newline_flag!: (Array[bool] lines) -> void
: (Array lines) -> void
() → Prism::node
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10672 def value @value end
The value to write to the constant. It can be any non-void expression.
FOO = :bar ^^^^ MyClass = Class.new ^^^^^^^^^
:call-seq: value -> Node
The value to write to the constant. It can be any non-void expression.
FOO = :bar ^^^^ MyClass = Class.new ^^^^^^^^^
: () -> Prism::node
Locations
Public Instance Methods
() → Location
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10641 def name_loc location = @name_loc return location if location.is_a?(Location) @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
() → Location
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10690 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
The Location of the = operator.
FOO = :bar ^
:category: Locations :call-seq: operator_loc -> Location
The Location of the = operator.
FOO = :bar ^
: () -> Location
Node Interface
These methods are present on all subclasses of Node. Read the node interface docs for more information.
Public Class Methods
Public Instance Methods
(_Visitor visitor) → untyped
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10531 def accept(visitor) visitor.visit_constant_write_node(self) end
() → Array[node?]
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10538 def child_nodes [value] end
() → Array[node]
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10555 def compact_child_nodes [value] end
(?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?value: Prism::node, ?operator_loc: Location) → ConstantWriteNode
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10565 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) ConstantWriteNode.new(source, node_id, location, flags, name, name_loc, value, operator_loc) end
Creates a copy of self with the given fields, using self as the template.
:call-seq: copy(**fields) -> ConstantWriteNode
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) -> ConstantWriteNode
() → Enumerator[node, void]
() { (node) → void } → void
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10546 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield value end
See Node.each_child_node.
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
Repository
Methods related to Relocation.
Public Instance Methods
(_Repository repository) → Relocation::Entry
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10652 def save_name_loc(repository) repository.enter(node_id, :name_loc) end
Save the name_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the name_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
(_Repository repository) → Relocation::Entry
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10701 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end
Save the operator_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the operator_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
Slicing
Public Instance Methods
() → String
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 10713 def operator operator_loc.slice end
Slice the location of operator_loc from the source.
:call-seq: operator -> String
Slice the location of operator_loc from the source.
: () -> String