class Prism::UntilNode
Represents the use of the until keyword, either in the block form or the modifier form.
bar until foo ^^^^^^^^^^^^^ until foo do bar end ^^^^^^^^^^^^^^^^^^^^
Public Class Methods
Source
# File lib/prism/node.rb, line 24348 def initialize(source, node_id, location, flags, keyword_loc, do_keyword_loc, closing_loc, predicate, statements) @source = source @node_id = node_id @location = location @flags = flags @keyword_loc = keyword_loc @do_keyword_loc = do_keyword_loc @closing_loc = closing_loc @predicate = predicate @statements = statements end
Initialize a new UntilNode node.
Public Instance Methods
Source
# File lib/prism/node.rb, line 24506 def predicate @predicate end
Returns the predicate attribute.
Source
# File lib/prism/node.rb, line 24514 def statements @statements end
Returns the statements attribute.
Flags
Public Instance Methods
Source
# File lib/prism/node.rb, line 24434 def begin_modifier? flags.anybits?(LoopFlags::BEGIN_MODIFIER) end
a loop after a begin statement, so the body is executed first before the condition
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 24484 def closing_loc location = @closing_loc case location when nil nil when Location location else @closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end
Returns the Location represented by closing_loc.
Source
# File lib/prism/node.rb, line 24461 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.
Source
# File lib/prism/node.rb, line 24443 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by keyword_loc.
Node Interface
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 24372 def accept(visitor) visitor.visit_until_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 24377 def child_nodes [predicate, statements] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 24398 def comment_targets [keyword_loc, *do_keyword_loc, *closing_loc, predicate, *statements] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 24390 def compact_child_nodes compact = [] #: Array[Prism::node] compact << predicate compact << statements if statements compact end
Source
# File lib/prism/node.rb, line 24406 def copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, do_keyword_loc: self.do_keyword_loc, closing_loc: self.closing_loc, predicate: self.predicate, statements: self.statements) UntilNode.new(source, node_id, location, flags, keyword_loc, do_keyword_loc, closing_loc, predicate, statements) end
Creates a copy of self with the given fields, using self as the template.
Source
# File lib/prism/node.rb, line 24382 def each_child_node return to_enum(:each_child_node) unless block_given? yield predicate yield statements if statements end
See Node.each_child_node.
Repository
Public Instance Methods
Source
# File lib/prism/node.rb, line 24499 def save_closing_loc(repository) repository.enter(node_id, :closing_loc) unless @closing_loc.nil? end
Save the closing_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 24476 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.
Source
# File lib/prism/node.rb, line 24452 def save_keyword_loc(repository) repository.enter(node_id, :keyword_loc) end
Save the keyword_loc location using the given saved source so that it can be retrieved later.
Slicing
Public Instance Methods
Source
# File lib/prism/node.rb, line 24540 def closing closing_loc&.slice end
Slice the location of closing_loc from the source.
Source
# File lib/prism/node.rb, line 24532 def do_keyword do_keyword_loc&.slice end
Slice the location of do_keyword_loc from the source.
Source
# File lib/prism/node.rb, line 24524 def keyword keyword_loc.slice end
Slice the location of keyword_loc from the source.