Class: Prism::YieldNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::YieldNode
- Defined in:
- lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c
Overview
Class Method Summary collapse
-
.type ⇒ :yield_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#arguments ⇒ ArgumentsNode?
:call-seq: arguments -> ArgumentsNode | nil.
-
#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, keyword_loc: self.keyword_loc, lparen_loc: self.lparen_loc, arguments: self.arguments, rparen_loc: self.rparen_loc) ⇒ YieldNode
:call-seq: copy(**fields) -> YieldNode.
-
#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, keyword_loc, lparen_loc, arguments, rparen_loc) ⇒ YieldNode
constructor
Initialize a new YieldNode node.
-
#inspect ⇒ String
: () -> String.
-
#keyword ⇒ String
:call-seq: keyword -> String.
-
#keyword_loc ⇒ Location
:category: Locations :call-seq: keyword_loc -> Location.
-
#lparen ⇒ String?
:call-seq: lparen -> String | nil.
-
#lparen_loc ⇒ Location?
:category: Locations :call-seq: lparen_loc -> Location | nil.
-
#rparen ⇒ String?
:call-seq: rparen -> String | nil.
-
#rparen_loc ⇒ Location?
:category: Locations :call-seq: rparen_loc -> Location | nil.
-
#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.
-
#save_lparen_loc(repository) ⇒ Relocation::Entry?
:category: Repository Save the lparen_loc location using the given saved source so that it can be retrieved later.
-
#save_rparen_loc(repository) ⇒ Relocation::Entry?
:category: Repository Save the rparen_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ :yield_node
See
Node#type.
Constructor Details
#initialize(source, node_id, location, flags, keyword_loc, lparen_loc, arguments, rparen_loc) ⇒ YieldNode
Initialize a new YieldNode node.
: (Source source, Integer node_id, Location location, Integer flags, Location keyword_loc, Location? lparen_loc, ArgumentsNode? arguments, Location? rparen_loc) -> void
33516 33517 33518 33519 33520 33521 33522 33523 33524 33525 |
# File 'lib/prism/node.rb', line 33516 def initialize(source, node_id, location, flags, keyword_loc, lparen_loc, arguments, rparen_loc) @source = source @node_id = node_id @location = location @flags = flags @keyword_loc = keyword_loc @lparen_loc = lparen_loc @arguments = arguments @rparen_loc = rparen_loc end |
Class Method Details
.type ⇒ :yield_node
See Node.type.
: () -> :yield_node
33612 33613 33614 |
# File 'lib/prism/node.rb', line 33612 def self.type :yield_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
33744 33745 33746 33747 33748 33749 33750 |
# File 'lib/prism/node.rb', line 33744 def ===(other) # :nodoc: other.is_a?(YieldNode) && (keyword_loc.nil? == other.keyword_loc.nil?) && (lparen_loc.nil? == other.lparen_loc.nil?) && (arguments === other.arguments) && (rparen_loc.nil? == other.rparen_loc.nil?) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
33541 33542 33543 |
# File 'lib/prism/node.rb', line 33541 def accept(visitor) visitor.visit_yield_node(self) end |
#arguments ⇒ ArgumentsNode?
:call-seq:
arguments -> ArgumentsNode | nil
Returns the arguments attribute.
: () -> ArgumentsNode?
33678 33679 33680 |
# File 'lib/prism/node.rb', line 33678 def arguments @arguments end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
33548 33549 33550 |
# File 'lib/prism/node.rb', line 33548 def child_nodes [arguments] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
33565 33566 33567 33568 33569 |
# File 'lib/prism/node.rb', line 33565 def compact_child_nodes compact = [] #: Array[Prism::node] if (arguments = self.arguments); compact << arguments; end compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, lparen_loc: self.lparen_loc, arguments: self.arguments, rparen_loc: self.rparen_loc) ⇒ YieldNode
:call-seq:
copy(**fields) -> YieldNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?keyword_loc: Location, ?lparen_loc: Location?, ?arguments: ArgumentsNode?, ?rparen_loc: Location?) -> YieldNode
33577 33578 33579 |
# File 'lib/prism/node.rb', line 33577 def copy(node_id: self.node_id, location: self.location, flags: self.flags, keyword_loc: self.keyword_loc, lparen_loc: self.lparen_loc, arguments: self.arguments, rparen_loc: self.rparen_loc) YieldNode.new(source, node_id, location, flags, keyword_loc, lparen_loc, arguments, rparen_loc) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
33584 33585 33586 33587 33588 33589 33590 33591 33592 33593 33594 33595 33596 33597 33598 33599 33600 |
# File 'lib/prism/node.rb', line 33584 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location keyword_loc lparen_loc arguments rparen_loc keyword lparen rparen]).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 :keyword_loc then deconstructed[:keyword_loc] = self.keyword_loc when :lparen_loc then deconstructed[:lparen_loc] = self.lparen_loc when :arguments then deconstructed[:arguments] = self.arguments when :rparen_loc then deconstructed[:rparen_loc] = self.rparen_loc when :keyword then deconstructed[:keyword] = self.keyword when :lparen then deconstructed[:lparen] = self.lparen when :rparen then deconstructed[:rparen] = self.rparen end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
33556 33557 33558 33559 33560 |
# File 'lib/prism/node.rb', line 33556 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? if (arguments = self.arguments); yield arguments; end end |
#inspect ⇒ String
: () -> String
33617 33618 33619 |
# File 'lib/prism/node.rb', line 33617 def inspect # :nodoc: InspectVisitor.compose(self) end |
#keyword ⇒ String
:call-seq:
keyword -> String
Slice the location of keyword_loc from the source.
: () -> String
33717 33718 33719 |
# File 'lib/prism/node.rb', line 33717 def keyword keyword_loc.slice end |
#keyword_loc ⇒ Location
:category: Locations :call-seq:
keyword_loc -> Location
Returns the Location represented by keyword_loc.
: () -> Location
33630 33631 33632 33633 33634 |
# File 'lib/prism/node.rb', line 33630 def keyword_loc location = @keyword_loc return location if location.is_a?(Location) @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#lparen ⇒ String?
:call-seq:
lparen -> String | nil
Slice the location of lparen_loc from the source.
: () -> String?
33727 33728 33729 |
# File 'lib/prism/node.rb', line 33727 def lparen lparen_loc&.slice end |
#lparen_loc ⇒ Location?
:category: Locations :call-seq:
lparen_loc -> Location | nil
Returns the Location represented by lparen_loc.
: () -> Location?
33652 33653 33654 33655 33656 33657 33658 33659 33660 33661 33662 |
# File 'lib/prism/node.rb', line 33652 def lparen_loc location = @lparen_loc case location when nil nil when Location location else @lparen_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end |
#rparen ⇒ String?
:call-seq:
rparen -> String | nil
Slice the location of rparen_loc from the source.
: () -> String?
33737 33738 33739 |
# File 'lib/prism/node.rb', line 33737 def rparen rparen_loc&.slice end |
#rparen_loc ⇒ Location?
:category: Locations :call-seq:
rparen_loc -> Location | nil
Returns the Location represented by rparen_loc.
: () -> Location?
33689 33690 33691 33692 33693 33694 33695 33696 33697 33698 33699 |
# File 'lib/prism/node.rb', line 33689 def rparen_loc location = @rparen_loc case location when nil nil when Location location else @rparen_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end 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
33641 33642 33643 |
# File 'lib/prism/node.rb', line 33641 def save_keyword_loc(repository) repository.enter(node_id, :keyword_loc) end |
#save_lparen_loc(repository) ⇒ Relocation::Entry?
:category: Repository Save the lparen_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry?
33669 33670 33671 |
# File 'lib/prism/node.rb', line 33669 def save_lparen_loc(repository) repository.enter(node_id, :lparen_loc) unless @lparen_loc.nil? end |
#save_rparen_loc(repository) ⇒ Relocation::Entry?
:category: Repository Save the rparen_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry?
33706 33707 33708 |
# File 'lib/prism/node.rb', line 33706 def save_rparen_loc(repository) repository.enter(node_id, :rparen_loc) unless @rparen_loc.nil? end |
#type ⇒ :yield_node
See Node#type.
: () -> :yield_node
33605 33606 33607 |
# File 'lib/prism/node.rb', line 33605 def type :yield_node end |