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 12098 def initialize(source, node_id, location, flags, pattern, statements, in_loc, then_loc) @source = source @node_id = node_id @location = location @flags = flags @pattern = pattern @statements = statements @in_loc = in_loc @then_loc = then_loc end
Initialize a new InNode node.
Public Instance Methods
Source
# File lib/prism/node.rb, line 12185 def pattern @pattern end
Returns the pattern attribute.
Source
# File lib/prism/node.rb, line 12193 def statements @statements end
Returns the statements attribute.
Locations
Public Instance Methods
Source
# File lib/prism/node.rb, line 12202 def in_loc location = @in_loc return location if location.is_a?(Location) @in_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Source
# File lib/prism/node.rb, line 12220 def then_loc location = @then_loc case location when nil nil when Location location else @then_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end
Node Interface
Public Class Methods
Public Instance Methods
Source
# File lib/prism/node.rb, line 12121 def accept(visitor) visitor.visit_in_node(self) end
See Node.accept.
Source
# File lib/prism/node.rb, line 12126 def child_nodes [pattern, statements] end
See Node.child_nodes.
Also aliased as: deconstruct
Source
# File lib/prism/node.rb, line 12147 def comment_targets [pattern, *statements, in_loc, *then_loc] #: Array[Prism::node | Location] end
See Node.comment_targets.
Source
# File lib/prism/node.rb, line 12139 def compact_child_nodes compact = [] #: Array[Prism::node] compact << pattern compact << statements if statements compact end
Source
# File lib/prism/node.rb, line 12155 def copy(node_id: self.node_id, location: self.location, flags: self.flags, pattern: self.pattern, statements: self.statements, in_loc: self.in_loc, then_loc: self.then_loc) InNode.new(source, node_id, location, flags, pattern, statements, in_loc, then_loc) end
Creates a copy of self with the given fields, using self as the template.
Source
# File lib/prism/node.rb, line 12131 def each_child_node return to_enum(:each_child_node) unless block_given? yield pattern yield statements if statements end
See Node.each_child_node.
Repository
Public Instance Methods
Source
# File lib/prism/node.rb, line 12211 def save_in_loc(repository) repository.enter(node_id, :in_loc) end
Save the in_loc location using the given saved source so that it can be retrieved later.
Source
# File lib/prism/node.rb, line 12235 def save_then_loc(repository) repository.enter(node_id, :then_loc) unless @then_loc.nil? end
Save the then_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 12244 def in in_loc.slice end
Slice the location of in_loc from the source.
Source
# File lib/prism/node.rb, line 12252 def then then_loc&.slice end
Slice the location of then_loc from the source.