Class: Prism::MatchPredicateNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::MatchPredicateNode
- Defined in:
- lib/prism/node.rb,
lib/prism/node_ext.rb,
sig/generated/prism/node.rbs,
sig/generated/prism/node_ext.rbs,
ext/prism/api_node.c
Overview
Class Method Summary collapse
-
.type ⇒ :match_predicate_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#child_nodes ⇒ Array[node?]
(also: #deconstruct)
See Node.child_nodes.
-
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value, pattern: self.pattern, keyword_loc: self.keyword_loc) ⇒ MatchPredicateNode
:call-seq: copy(**fields) -> MatchPredicateNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#initialize(source, node_id, location, flags, value, pattern, keyword_loc) ⇒ MatchPredicateNode
constructor
Initialize a new MatchPredicateNode node.
-
#inspect ⇒ String
: () -> String.
-
#keyword ⇒ String
:call-seq: keyword -> String.
-
#keyword_loc ⇒ Location
:category: Locations :call-seq: keyword_loc -> Location.
-
#operator ⇒ String
: () -> String.
-
#operator_loc ⇒ Location
: () -> Location.
-
#pattern ⇒ Prism::node
:call-seq: pattern -> Node.
-
#save_keyword_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the keyword_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ :match_predicate_node
See
Node#type. -
#value ⇒ Prism::node
:call-seq: value -> Node.
Constructor Details
#initialize(source, node_id, location, flags, value, pattern, keyword_loc) ⇒ MatchPredicateNode
Initialize a new MatchPredicateNode node.
: (Source source, Integer node_id, Location location, Integer flags, Prism::node value, Prism::node pattern, Location keyword_loc) -> void
22978 22979 22980 22981 22982 22983 22984 22985 22986 |
# File 'lib/prism/node.rb', line 22978 def initialize(source, node_id, location, flags, value, pattern, keyword_loc) @source = source @node_id = node_id @location = location @flags = flags @value = value @pattern = pattern @keyword_loc = keyword_loc end |
Class Method Details
.type ⇒ :match_predicate_node
See Node.type.
: () -> :match_predicate_node
23069 23070 23071 |
# File 'lib/prism/node.rb', line 23069 def self.type :match_predicate_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
23137 23138 23139 23140 23141 23142 |
# File 'lib/prism/node.rb', line 23137 def ===(other) # :nodoc: other.is_a?(MatchPredicateNode) && (value === other.value) && (pattern === other.pattern) && (keyword_loc.nil? == other.keyword_loc.nil?) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
23002 23003 23004 |
# File 'lib/prism/node.rb', line 23002 def accept(visitor) visitor.visit_match_predicate_node(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
23009 23010 23011 |
# File 'lib/prism/node.rb', line 23009 def child_nodes [value, pattern] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
23027 23028 23029 |
# File 'lib/prism/node.rb', line 23027 def compact_child_nodes [value, pattern] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value, pattern: self.pattern, keyword_loc: self.keyword_loc) ⇒ MatchPredicateNode
:call-seq:
copy(**fields) -> MatchPredicateNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Prism::node, ?pattern: Prism::node, ?keyword_loc: Location) -> MatchPredicateNode
23037 23038 23039 |
# File 'lib/prism/node.rb', line 23037 def copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value, pattern: self.pattern, keyword_loc: self.keyword_loc) MatchPredicateNode.new(source, node_id, location, flags, value, pattern, keyword_loc) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
23044 23045 23046 23047 23048 23049 23050 23051 23052 23053 23054 23055 23056 23057 |
# File 'lib/prism/node.rb', line 23044 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location value pattern keyword_loc keyword]).each_with_object( {} #: Hash[Symbol, untyped] ) do |key, deconstructed| case key when :node_id then deconstructed[:node_id] = self.node_id when :location then deconstructed[:location] = self.location when :value then deconstructed[:value] = self.value when :pattern then deconstructed[:pattern] = self.pattern when :keyword_loc then deconstructed[:keyword_loc] = self.keyword_loc when :keyword then deconstructed[:keyword] = self.keyword end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
23017 23018 23019 23020 23021 23022 |
# File 'lib/prism/node.rb', line 23017 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield value yield pattern end |
#inspect ⇒ String
: () -> String
23074 23075 23076 |
# File 'lib/prism/node.rb', line 23074 def inspect # :nodoc: InspectVisitor.compose(self) end |
#keyword ⇒ String
:call-seq:
keyword -> String
Slice the location of keyword_loc from the source.
: () -> String
23130 23131 23132 |
# File 'lib/prism/node.rb', line 23130 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Location
:category: Locations :call-seq:
keyword_loc -> Location
Returns the Location represented by keyword_loc.
: () -> Location
23107 23108 23109 23110 23111 |
# File 'lib/prism/node.rb', line 23107 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#operator ⇒ String
: () -> String
414 415 416 |
# File 'lib/prism/node_ext.rb', line 414 def operator # :nodoc keyword end |
#operator_loc ⇒ Location
: () -> Location
419 420 421 |
# File 'lib/prism/node_ext.rb', line 419 def operator_loc # :nodoc keyword_loc end |
#pattern ⇒ Prism::node
:call-seq:
pattern -> Node
Returns the pattern attribute.
: () -> Prism::node
23096 23097 23098 |
# File 'lib/prism/node.rb', line 23096 def pattern @pattern end |
#save_keyword_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the keyword_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
23118 23119 23120 |
# File 'lib/prism/node.rb', line 23118 def save_keyword_loc(repository) repository.enter(node_id, :keyword_loc) end |
#type ⇒ :match_predicate_node
See Node#type.
: () -> :match_predicate_node
23062 23063 23064 |
# File 'lib/prism/node.rb', line 23062 def type :match_predicate_node end |
#value ⇒ Prism::node
:call-seq:
value -> Node
Returns the value attribute.
: () -> Prism::node
23086 23087 23088 |
# File 'lib/prism/node.rb', line 23086 def value @value end |