Class: Prism::EmbeddedStatementsNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::EmbeddedStatementsNode
- Defined in:
- lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c
Overview
Class Method Summary collapse
-
.type ⇒ :embedded_statements_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.
-
#closing ⇒ String
:call-seq: closing -> String.
-
#closing_loc ⇒ Location
:category: Locations :call-seq: closing_loc -> Location.
-
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, opening_loc: self.opening_loc, statements: self.statements, closing_loc: self.closing_loc) ⇒ EmbeddedStatementsNode
:call-seq: copy(**fields) -> EmbeddedStatementsNode.
-
#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, opening_loc, statements, closing_loc) ⇒ EmbeddedStatementsNode
constructor
Initialize a new EmbeddedStatementsNode node.
-
#inspect ⇒ String
: () -> String.
-
#opening ⇒ String
:call-seq: opening -> String.
-
#opening_loc ⇒ Location
:category: Locations :call-seq: opening_loc -> Location.
-
#save_closing_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the closing_loc location using the given saved source so that it can be retrieved later.
-
#save_opening_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the opening_loc location using the given saved source so that it can be retrieved later.
-
#statements ⇒ StatementsNode?
:call-seq: statements -> StatementsNode | nil.
-
#type ⇒ :embedded_statements_node
See
Node#type.
Constructor Details
#initialize(source, node_id, location, flags, opening_loc, statements, closing_loc) ⇒ EmbeddedStatementsNode
Initialize a new EmbeddedStatementsNode node.
: (Source source, Integer node_id, Location location, Integer flags, Location opening_loc, StatementsNode? statements, Location closing_loc) -> void
11677 11678 11679 11680 11681 11682 11683 11684 11685 |
# File 'lib/prism/node.rb', line 11677 def initialize(source, node_id, location, flags, opening_loc, statements, closing_loc) @source = source @node_id = node_id @location = location @flags = flags @opening_loc = opening_loc @statements = statements @closing_loc = closing_loc end |
Class Method Details
.type ⇒ :embedded_statements_node
See Node.type.
: () -> :embedded_statements_node
11770 11771 11772 |
# File 'lib/prism/node.rb', line 11770 def self.type :embedded_statements_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
11860 11861 11862 11863 11864 11865 |
# File 'lib/prism/node.rb', line 11860 def ===(other) # :nodoc: other.is_a?(EmbeddedStatementsNode) && (opening_loc.nil? == other.opening_loc.nil?) && (statements === other.statements) && (closing_loc.nil? == other.closing_loc.nil?) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
11701 11702 11703 |
# File 'lib/prism/node.rb', line 11701 def accept(visitor) visitor.(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
11708 11709 11710 |
# File 'lib/prism/node.rb', line 11708 def child_nodes [statements] end |
#closing ⇒ String
:call-seq:
closing -> String
Slice the location of closing_loc from the source.
: () -> String
11853 11854 11855 |
# File 'lib/prism/node.rb', line 11853 def closing closing_loc.slice end |
#closing_loc ⇒ Location
:category: Locations :call-seq:
closing_loc -> Location
Returns the Location represented by closing_loc.
: () -> Location
11820 11821 11822 11823 11824 |
# File 'lib/prism/node.rb', line 11820 def closing_loc location = @closing_loc return location if location.is_a?(Location) @closing_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
11725 11726 11727 11728 11729 |
# File 'lib/prism/node.rb', line 11725 def compact_child_nodes compact = [] #: Array[Prism::node] if (statements = self.statements); compact << statements; end compact end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, opening_loc: self.opening_loc, statements: self.statements, closing_loc: self.closing_loc) ⇒ EmbeddedStatementsNode
:call-seq:
copy(**fields) -> EmbeddedStatementsNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?statements: StatementsNode?, ?closing_loc: Location) -> EmbeddedStatementsNode
11737 11738 11739 |
# File 'lib/prism/node.rb', line 11737 def copy(node_id: self.node_id, location: self.location, flags: self.flags, opening_loc: self.opening_loc, statements: self.statements, closing_loc: self.closing_loc) EmbeddedStatementsNode.new(source, node_id, location, flags, opening_loc, statements, closing_loc) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 |
# File 'lib/prism/node.rb', line 11744 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location opening_loc statements closing_loc opening closing]).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 :opening_loc then deconstructed[:opening_loc] = self.opening_loc when :statements then deconstructed[:statements] = self.statements when :closing_loc then deconstructed[:closing_loc] = self.closing_loc when :opening then deconstructed[:opening] = self.opening when :closing then deconstructed[:closing] = self.closing end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
11716 11717 11718 11719 11720 |
# File 'lib/prism/node.rb', line 11716 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? if (statements = self.statements); yield statements; end end |
#inspect ⇒ String
: () -> String
11775 11776 11777 |
# File 'lib/prism/node.rb', line 11775 def inspect # :nodoc: InspectVisitor.compose(self) end |
#opening ⇒ String
:call-seq:
opening -> String
Slice the location of opening_loc from the source.
: () -> String
11843 11844 11845 |
# File 'lib/prism/node.rb', line 11843 def opening opening_loc.slice end |
#opening_loc ⇒ Location
:category: Locations :call-seq:
opening_loc -> Location
Returns the Location represented by opening_loc.
: () -> Location
11788 11789 11790 11791 11792 |
# File 'lib/prism/node.rb', line 11788 def opening_loc location = @opening_loc return location if location.is_a?(Location) @opening_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_closing_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the closing_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
11831 11832 11833 |
# File 'lib/prism/node.rb', line 11831 def save_closing_loc(repository) repository.enter(node_id, :closing_loc) end |
#save_opening_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the opening_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
11799 11800 11801 |
# File 'lib/prism/node.rb', line 11799 def save_opening_loc(repository) repository.enter(node_id, :opening_loc) end |
#statements ⇒ StatementsNode?
:call-seq:
statements -> StatementsNode | nil
Returns the statements attribute.
: () -> StatementsNode?
11809 11810 11811 |
# File 'lib/prism/node.rb', line 11809 def statements @statements end |
#type ⇒ :embedded_statements_node
See Node#type.
: () -> :embedded_statements_node
11763 11764 11765 |
# File 'lib/prism/node.rb', line 11763 def type :embedded_statements_node end |