123456789_123456789_123456789_123456789_123456789_

Class: Prism::UntilNode

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, PrismNode
Instance Chain:
self, PrismNode
Inherits: PrismNode
Defined in: lib/prism/node.rb,
ext/prism/api_node.c,
lib/prism/parse_result/newlines.rb

Overview

Represents the use of the until keyword, either in the block form or the modifier form.

bar until foo
^^^^^^^^^^^^^

until foo do bar end
^^^^^^^^^^^^^^^^^^^^

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(source, node_id, location, flags, keyword_loc, closing_loc, predicate, statements) ⇒ UntilNode

Initialize a new UntilNode node.

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15762

def initialize(source, node_id, location, flags, keyword_loc, closing_loc, predicate, statements)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @keyword_loc = keyword_loc
  @closing_loc = closing_loc
  @predicate = predicate
  @statements = statements
end

Class Method Details

.type

Return a symbol representation of this node type. See Node::type.

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15859

def self.type
  :until_node
end

Instance Attribute Details

#begin_modifier? ⇒ Boolean (readonly)

def begin_modifier?: () -> bool

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15810

def begin_modifier?
  flags.anybits?(LoopFlags::BEGIN_MODIFIER)
end

#predicate (readonly)

attr_reader predicate: Prism.node

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15835

attr_reader :predicate

#statements (readonly)

attr_reader statements: StatementsNode?

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15837

attr_reader :statements

Instance Method Details

#===(other)

Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15865

def ===(other)
  other.is_a?(UntilNode) &&
    (flags === other.flags) &&
    (keyword_loc.nil? == other.keyword_loc.nil?) &&
    (closing_loc.nil? == other.closing_loc.nil?) &&
    (predicate === other.predicate) &&
    (statements === other.statements)
end

#accept(visitor)

def accept: (Visitor visitor) -> void

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15774

def accept(visitor)
  visitor.visit_until_node(self)
end

#child_nodes Also known as: #deconstruct

def child_nodes: () -> Array[nil | Node]

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15779

def child_nodes
  [predicate, statements]
end

#closing

def closing: () -> String?

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15844

def closing
  closing_loc&.slice
end

#closing_loc

attr_reader closing_loc: Location?

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15822

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

#comment_targets

def comment_targets: () -> Array[Node | Location]

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15792

def comment_targets
  [keyword_loc, *closing_loc, predicate, *statements] #: Array[Prism::node | Location]
end

#compact_child_nodes

def compact_child_nodes: () -> Array

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15784

def compact_child_nodes
  compact = [] #: Array[Prism::node]
  compact << predicate
  compact << statements if statements
  compact
end

#copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, closing_loc: self.closing_loc, predicate: self.predicate, statements: self.statements)

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?closing_loc: Location?, ?predicate: Prism.node, ?statements: StatementsNode?) -> UntilNode

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15797

def copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, closing_loc: self.closing_loc, predicate: self.predicate, statements: self.statements)
  UntilNode.new(source, node_id, location, flags, keyword_loc, closing_loc, predicate, statements)
end

#deconstruct

Alias for #child_nodes.

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15802

alias deconstruct child_nodes

#deconstruct_keys(keys)

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, keyword_loc: Location, closing_loc: Location?, predicate: Prism.node, statements: StatementsNode? }

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15805

def deconstruct_keys(keys)
  { node_id: node_id, location: location, keyword_loc: keyword_loc, closing_loc: closing_loc, predicate: predicate, statements: statements }
end

#inspect

def inspect -> String

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15849

def inspect
  InspectVisitor.compose(self)
end

#keyword

def keyword: () -> String

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15839

def keyword
  keyword_loc.slice
end

#keyword_loc

attr_reader keyword_loc: Location

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15815

def keyword_loc
  location = @keyword_loc
  return location if location.is_a?(Location)
  @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
end

#newline_flag!(lines)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/prism/parse_result/newlines.rb', line 104

def newline_flag!(lines) # :nodoc:
  predicate.newline_flag!(lines)
end

#type

Return a symbol representation of this node type. See Node#type.

[ GitHub ]

  
# File 'lib/prism/node.rb', line 15854

def type
  :until_node
end