class Prism::InNode
Represents the use of the in keyword in a case statement.
case a; in b then c end
^^^^^^^^^^^
Public Class Methods
Source
# File lib/prism/node.rb, line 15990 def initialize(source, node_id, location, flags, pattern, statements, in_keyword_loc, then_keyword_loc) @source = source @node_id = node_id @location = location @flags = flags @pattern = pattern @statements = statements @in_keyword_loc = in_keyword_loc @then_keyword_loc = then_keyword_loc end
Initialize a new InNode node.
Public Instance Methods
Source
# File lib/prism/node_ext.rb, line 396 def in_loc # :nodoc in_keyword_loc end
: () -> Location
Source
# File lib/prism/node.rb, line 16111 def pattern @pattern end
Returns the pattern attribute.
Source
# File lib/prism/node.rb, line 16121 def statements @statements end
Returns the statements attribute.
Source
# File lib/prism/node_ext.rb, line 401 def then # :nodoc then_keyword end
: () -> String?
Source
# File lib/prism/node_ext.rb, line 406 def then_loc # :nodoc then_keyword_loc end
: () -> Location?
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 16132 def in_keyword_loc location = @in_keyword_loc return location if location.is_a?(Location) @in_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Returns the Location represented by in_keyword_loc.
Source
# File lib/prism/node.rb, line 16154 def then_keyword_loc location = @then_keyword_loc case location when nil nil when Location location else @then_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end
Returns the Location represented by then_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 16015 def accept(visitor) visitor.visit_in_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 16022 def child_nodes [pattern, statements] end
See Node.child_nodes.
Source
# File lib/prism/node.rb, line 16050 def comment_targets [pattern, *statements, in_keyword_loc, *then_keyword_loc] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 16040 def compact_child_nodes compact = [] #: Array[Prism::node] compact << pattern if (statements = self.statements); compact << statements; end compact end
Source
# File lib/prism/node.rb, line 16060 def copy(node_id: self.node_id, location: self.location, flags: self.flags, pattern: self.pattern, statements: self.statements, in_keyword_loc: self.in_keyword_loc, then_keyword_loc: self.then_keyword_loc) InNode.new(source, node_id, location, flags, pattern, statements, in_keyword_loc, then_keyword_loc) end
Creates a copy of self with the given fields, using self as the template.
Source
# File lib/prism/node.rb, line 16030 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield pattern 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 16143 def save_in_keyword_loc(repository) repository.enter(node_id, :in_keyword_loc) end
Save the in_keyword_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 16171 def save_then_keyword_loc(repository) repository.enter(node_id, :then_keyword_loc) unless @then_keyword_loc.nil? end
Save the then_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 16182 def in_keyword in_keyword_loc.slice end
Slice the location of in_keyword_loc from the source.
Source
# File lib/prism/node.rb, line 16192 def then_keyword then_keyword_loc&.slice end
Slice the location of then_keyword_loc from the source.