class Prism::WhileNode
Represents the use of the while keyword, either in the block form or the modifier form.
bar while foo ^^^^^^^^^^^^^ while foo do bar end ^^^^^^^^^^^^^^^^^^^^
Represents the use of the while keyword, either in the block form or the modifier form.
bar while foo ^^^^^^^^^^^^^ while foo do bar end ^^^^^^^^^^^^^^^^^^^^
Public Class Methods
(Source source, Integer node_id, Location location, Integer flags, Location while_keyword_loc, Location? do_keyword_loc, Location? end_keyword_loc, Prism::node predicate, StatementsNode? statements) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 32980 def initialize(source, node_id, location, flags, while_keyword_loc, do_keyword_loc, end_keyword_loc, predicate, statements) @source = source @node_id = node_id @location = location @flags = flags @while_keyword_loc = while_keyword_loc @do_keyword_loc = do_keyword_loc @end_keyword_loc = end_keyword_loc @predicate = predicate @statements = statements end
Initialize a new WhileNode node.
Initialize a new WhileNode node.
: (Source source, Integer node_id, Location location, Integer flags, Location while_keyword_loc, Location? do_keyword_loc, Location? end_keyword_loc, Prism::node predicate, StatementsNode? statements) -> 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 21122
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_ext.rbs, line 277
def closing: () -> String?
: () -> String?
() → Location?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node_ext.rbs, line 280
def closing_loc: () -> Location?
: () -> Location?
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 21012
def deconstruct_keys: (Array[Symbol]? keys) -> Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node.rbs, line 21025
def inspect: () -> String
: () -> String
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node_ext.rbs, line 271
def keyword: () -> String
: () -> String
() → Location
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/sig/generated/prism/node_ext.rbs, line 274
def keyword_loc: () -> Location
: () -> Location
(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 141
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 33181 def predicate @predicate end
Returns the predicate attribute.
:call-seq: predicate -> Node
Returns the predicate attribute.
: () -> Prism::node
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 33191 def statements @statements end
Returns the statements attribute.
:call-seq: statements -> StatementsNode | nil
Returns the statements attribute.
: () -> StatementsNode?
Flags
Public Instance Methods
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 33095 def begin_modifier? flags.anybits?(LoopFlags::BEGIN_MODIFIER) end
a loop after a begin statement, so the body is executed first before the condition
:category: Flags a loop after a begin statement, so the body is executed first before the condition
: () -> bool
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 33128 def do_keyword_loc location = @do_keyword_loc case location when nil nil when Location location else @do_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end
Returns the Location represented by do_keyword_loc.
:category: Locations :call-seq: do_keyword_loc -> Location | nil
Returns the Location represented by do_keyword_loc.
: () -> Location?
() → Location?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 33155 def end_keyword_loc location = @end_keyword_loc case location when nil nil when Location location else @end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end
Returns the Location represented by end_keyword_loc.
:category: Locations :call-seq: end_keyword_loc -> Location | nil
Returns the Location represented by end_keyword_loc.
: () -> Location?
() → Location
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 33106 def while_keyword_loc location = @while_keyword_loc return location if location.is_a?(Location) @while_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by while_keyword_loc.
:category: Locations :call-seq: while_keyword_loc -> Location
Returns the Location represented by while_keyword_loc.
: () -> 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 33006 def accept(visitor) visitor.visit_while_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 33013 def child_nodes [predicate, statements] 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 33031 def compact_child_nodes compact = [] #: Array[Prism::node] compact << predicate if (statements = self.statements); compact << statements; end compact end
(?node_id: Integer, ?location: Location, ?flags: Integer, ?while_keyword_loc: Location, ?do_keyword_loc: Location?, ?end_keyword_loc: Location?, ?predicate: Prism::node, ?statements: StatementsNode?) → WhileNode
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 33044 def copy(node_id: self.node_id, location: self.location, flags: self.flags, while_keyword_loc: self.while_keyword_loc, do_keyword_loc: self.do_keyword_loc, end_keyword_loc: self.end_keyword_loc, predicate: self.predicate, statements: self.statements) WhileNode.new(source, node_id, location, flags, while_keyword_loc, do_keyword_loc, end_keyword_loc, predicate, statements) end
Creates a copy of self with the given fields, using self as the template.
:call-seq: copy(**fields) -> WhileNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?while_keyword_loc: Location, ?do_keyword_loc: Location?, ?end_keyword_loc: Location?, ?predicate: Prism::node, ?statements: StatementsNode?) -> WhileNode
() → 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 33021 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield predicate if (statements = self.statements); yield statements; end 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 33145 def save_do_keyword_loc(repository) repository.enter(node_id, :do_keyword_loc) unless @do_keyword_loc.nil? end
Save the do_keyword_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the do_keyword_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 33172 def save_end_keyword_loc(repository) repository.enter(node_id, :end_keyword_loc) unless @end_keyword_loc.nil? end
Save the end_keyword_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the end_keyword_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 33117 def save_while_keyword_loc(repository) repository.enter(node_id, :while_keyword_loc) end
Save the while_keyword_loc location using the given saved source so that it can be retrieved later.
:category: Repository Save the while_keyword_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
Slicing
Public Instance Methods
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 33213 def do_keyword do_keyword_loc&.slice end
Slice the location of do_keyword_loc from the source.
:call-seq: do_keyword -> String | nil
Slice the location of do_keyword_loc from the source.
: () -> String?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 33223 def end_keyword end_keyword_loc&.slice end
Slice the location of end_keyword_loc from the source.
:call-seq: end_keyword -> String | nil
Slice the location of end_keyword_loc from the source.
: () -> String?
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-2.1.0-x86_64-linux-gnu/lib/prism/node.rb, line 33203 def while_keyword while_keyword_loc.slice end
Slice the location of while_keyword_loc from the source.
:call-seq: while_keyword -> String
Slice the location of while_keyword_loc from the source.
: () -> String