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 32066 def initialize(source, node_id, location, flags, until_keyword_loc, do_keyword_loc, end_keyword_loc, predicate, statements) @source = source @node_id = node_id @location = location @flags = flags @until_keyword_loc = until_keyword_loc @do_keyword_loc = do_keyword_loc @end_keyword_loc = end_keyword_loc @predicate = predicate @statements = statements end
Initialize a new UntilNode node.
Public Instance Methods
Source
# File lib/prism/node_ext.rb, line 447 def closing # :nodoc end_keyword end
: () -> String?
Source
# File lib/prism/node_ext.rb, line 452 def closing_loc # :nodoc end_keyword_loc end
: () -> Location?
Source
# File lib/prism/node_ext.rb, line 437 def keyword # :nodoc until_keyword end
: () -> String
Source
# File lib/prism/node_ext.rb, line 442 def keyword_loc # :nodoc until_keyword_loc end
: () -> Location
Source
# File lib/prism/node.rb, line 32274 def predicate @predicate end
Returns the predicate attribute.
Source
# File lib/prism/node.rb, line 32284 def statements @statements end
Returns the statements attribute.
Flags
Public Instance Methods
Source
# File lib/prism/node.rb, line 32188 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 32221 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 32248 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.
Source
# File lib/prism/node.rb, line 32199 def until_keyword_loc location = @until_keyword_loc return location if location.is_a?(Location) @until_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by until_keyword_loc.
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
Source
# File lib/prism/node.rb, line 32092 def accept(visitor) visitor.visit_until_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 32099 def child_nodes [predicate, statements] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 32127 def comment_targets [until_keyword_loc, *do_keyword_loc, *end_keyword_loc, predicate, *statements] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 32117 def compact_child_nodes compact = [] #: Array[Prism::node] compact << predicate if (statements = self.statements); compact << statements; end compact end
Source
# File lib/prism/node.rb, line 32137 def copy(node_id: self.node_id, location: self.location, flags: self.flags, until_keyword_loc: self.until_keyword_loc, do_keyword_loc: self.do_keyword_loc, end_keyword_loc: self.end_keyword_loc, predicate: self.predicate, statements: self.statements) UntilNode.new(source, node_id, location, flags, until_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.
Source
# File lib/prism/node.rb, line 32107 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.
Repository
Methods related to Relocation.
Public Instance Methods
Source
# File lib/prism/node.rb, line 32238 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 32265 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.
Source
# File lib/prism/node.rb, line 32210 def save_until_keyword_loc(repository) repository.enter(node_id, :until_keyword_loc) end
Save the until_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 32306 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 32316 def end_keyword end_keyword_loc&.slice end
Slice the location of end_keyword_loc from the source.
Source
# File lib/prism/node.rb, line 32296 def until_keyword until_keyword_loc.slice end
Slice the location of until_keyword_loc from the source.