class Prism::CaseMatchNode
Stellt die Verwendung einer case-Anweisungse für Pattern Matching dar.
case true in false end ^^^^^^^^^
Attribute
Stellt die Bedingungen des case-Matches dar.
case true; in false; end
^^^^^^^^
Stellt die else-Klausel des case-Matches dar.
case true; in false; else; end
^^^^
Stellt das Prädikat des case-Matches dar. Dies kann entweder nil oder ein beliebiger Nicht-Void-Ausdruck sein.
case true; in false; end ^^^^
Öffentliche Klassenmethoden
Source
# File lib/prism/node.rb, line 3570 def initialize(source, node_id, location, flags, predicate, conditions, else_clause, case_keyword_loc, end_keyword_loc) @source = source @node_id = node_id @location = location @flags = flags @predicate = predicate @conditions = conditions @else_clause = else_clause @case_keyword_loc = case_keyword_loc @end_keyword_loc = end_keyword_loc end
Initialisiert einen neuen CaseMatchNode.
Source
# File lib/prism/node.rb, line 3690 def self.type :case_match_node end
Gibt eine symbolische Darstellung dieses Knotentyps zurück. Siehe Node::type.
Öffentliche Instanzmethoden
Source
# File lib/prism/node.rb, line 3696 def ===(other) other.is_a?(CaseMatchNode) && (predicate === other.predicate) && (conditions.length == other.conditions.length) && conditions.zip(other.conditions).all? { |left, right| left === right } && (else_clause === other.else_clause) && (case_keyword_loc.nil? == other.case_keyword_loc.nil?) && (end_keyword_loc.nil? == other.end_keyword_loc.nil?) end
Implementiert die Fallgleichheit für den Knoten. Dies ist effektiv ==, aber ohne den Wert von Standorten zu vergleichen. Standorte werden nur auf Anwesenheit geprüft.
Source
# File lib/prism/node.rb, line 3583 def accept(visitor) visitor.visit_case_match_node(self) end
def accept: (Visitor visitor) -> void
Source
# File lib/prism/node.rb, line 3670 def case_keyword case_keyword_loc.slice end
def case_keyword: () -> String
Source
# File lib/prism/node.rb, line 3641 def case_keyword_loc location = @case_keyword_loc return location if location.is_a?(Location) @case_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Stellt den Speicherort des case-Schlüsselworts dar.
case true; in false; end ^^^^
Source
# File lib/prism/node.rb, line 3588 def child_nodes [predicate, *conditions, else_clause] end
def child_nodes: () -> Array
Source
# File lib/prism/node.rb, line 3602 def comment_targets [*predicate, *conditions, *else_clause, case_keyword_loc, end_keyword_loc] #: Array[Prism::node | Location] end
def comment_targets: () -> Array[Node | Location]
Source
# File lib/prism/node.rb, line 3593 def compact_child_nodes compact = [] #: Array[Prism::node] compact << predicate if predicate compact.concat(conditions) compact << else_clause if else_clause compact end
def compact_child_nodes: () -> Array
Source
# File lib/prism/node_ext.rb, line 470 def consequent deprecated("else_clause") else_clause end
Gibt die else-Klausel des case-Match-Knotens zurück. Diese Methode ist veraltet und wird durch else_clause ersetzt.
Source
# File lib/prism/node.rb, line 3607 def copy(node_id: self.node_id, location: self.location, flags: self.flags, predicate: self.predicate, conditions: self.conditions, else_clause: self.else_clause, case_keyword_loc: self.case_keyword_loc, end_keyword_loc: self.end_keyword_loc) CaseMatchNode.new(source, node_id, location, flags, predicate, conditions, else_clause, case_keyword_loc, end_keyword_loc) end
Source
# File lib/prism/node.rb, line 3615 def deconstruct_keys(keys) { node_id: node_id, location: location, predicate: predicate, conditions: conditions, else_clause: else_clause, case_keyword_loc: case_keyword_loc, end_keyword_loc: end_keyword_loc } end
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, predicate: Prism::node?, conditions: Array, else_clause: ElseNode?, case_keyword_loc: Location, end_keyword_loc: Location }
Source
# File lib/prism/node.rb, line 3675 def end_keyword end_keyword_loc.slice end
def end_keyword: () -> String
Source
# File lib/prism/node.rb, line 3657 def end_keyword_loc location = @end_keyword_loc return location if location.is_a?(Location) @end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
Stellt den Speicherort des end-Schlüsselworts dar.
case true; in false; end
^^^
Source
# File lib/prism/node.rb, line 3680 def inspect InspectVisitor.compose(self) end
def inspect -> String
Source
# File lib/prism/node.rb, line 3649 def save_case_keyword_loc(repository) repository.enter(node_id, :case_keyword_loc) end
Speichert den Speicherort case_keyword_loc unter Verwendung der angegebenen gespeicherten Quelle, damit er später abgerufen werden kann.
Source
# File lib/prism/node.rb, line 3665 def save_end_keyword_loc(repository) repository.enter(node_id, :end_keyword_loc) end
Speichert den Speicherort end_keyword_loc unter Verwendung der angegebenen gespeicherten Quelle, damit er später abgerufen werden kann.