Class: Prism::EmbeddedVariableNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::EmbeddedVariableNode
- Defined in:
- lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c
Overview
Class Method Summary collapse
-
.type ⇒ :embedded_variable_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, operator_loc: self.operator_loc, variable: self.variable) ⇒ EmbeddedVariableNode
:call-seq: copy(**fields) -> EmbeddedVariableNode.
-
#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, operator_loc, variable) ⇒ EmbeddedVariableNode
constructor
Initialize a new EmbeddedVariableNode node.
-
#inspect ⇒ String
: () -> String.
-
#operator ⇒ String
:call-seq: operator -> String.
-
#operator_loc ⇒ Location
:category: Locations :call-seq: operator_loc -> Location.
-
#save_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the operator_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ :embedded_variable_node
See
Node#type. -
#variable ⇒ InstanceVariableReadNode, ...
:call-seq: variable -> InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode.
Constructor Details
#initialize(source, node_id, location, flags, operator_loc, variable) ⇒ EmbeddedVariableNode
Initialize a new EmbeddedVariableNode node.
: (Source source, Integer node_id, Location location, Integer flags, Location operator_loc, (InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) variable) -> void
11883 11884 11885 11886 11887 11888 11889 11890 |
# File 'lib/prism/node.rb', line 11883 def initialize(source, node_id, location, flags, operator_loc, variable) @source = source @node_id = node_id @location = location @flags = flags @operator_loc = operator_loc @variable = variable end |
Class Method Details
.type ⇒ :embedded_variable_node
See Node.type.
: () -> :embedded_variable_node
11971 11972 11973 |
# File 'lib/prism/node.rb', line 11971 def self.type :embedded_variable_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
12029 12030 12031 12032 12033 |
# File 'lib/prism/node.rb', line 12029 def ===(other) # :nodoc: other.is_a?(EmbeddedVariableNode) && (operator_loc.nil? == other.operator_loc.nil?) && (variable === other.variable) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
11906 11907 11908 |
# File 'lib/prism/node.rb', line 11906 def accept(visitor) visitor.(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
11913 11914 11915 |
# File 'lib/prism/node.rb', line 11913 def child_nodes [variable] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
11930 11931 11932 |
# File 'lib/prism/node.rb', line 11930 def compact_child_nodes [variable] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, operator_loc: self.operator_loc, variable: self.variable) ⇒ EmbeddedVariableNode
:call-seq:
copy(**fields) -> EmbeddedVariableNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?variable: (InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode)) -> EmbeddedVariableNode
11940 11941 11942 |
# File 'lib/prism/node.rb', line 11940 def copy(node_id: self.node_id, location: self.location, flags: self.flags, operator_loc: self.operator_loc, variable: self.variable) EmbeddedVariableNode.new(source, node_id, location, flags, operator_loc, variable) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 |
# File 'lib/prism/node.rb', line 11947 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location operator_loc variable operator]).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 :operator_loc then deconstructed[:operator_loc] = self.operator_loc when :variable then deconstructed[:variable] = self.variable when :operator then deconstructed[:operator] = self.operator end end end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
11921 11922 11923 11924 11925 |
# File 'lib/prism/node.rb', line 11921 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield variable end |
#inspect ⇒ String
: () -> String
11976 11977 11978 |
# File 'lib/prism/node.rb', line 11976 def inspect # :nodoc: InspectVisitor.compose(self) end |
#operator ⇒ String
:call-seq:
operator -> String
Slice the location of operator_loc from the source.
: () -> String
12022 12023 12024 |
# File 'lib/prism/node.rb', line 12022 def operator operator_loc.slice end |
#operator_loc ⇒ Location
:category: Locations :call-seq:
operator_loc -> Location
Returns the Location represented by operator_loc.
: () -> Location
11989 11990 11991 11992 11993 |
# File 'lib/prism/node.rb', line 11989 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the operator_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
12000 12001 12002 |
# File 'lib/prism/node.rb', line 12000 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end |
#type ⇒ :embedded_variable_node
See Node#type.
: () -> :embedded_variable_node
11964 11965 11966 |
# File 'lib/prism/node.rb', line 11964 def type :embedded_variable_node end |
#variable ⇒ InstanceVariableReadNode, ...
:call-seq:
variable -> InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode
Returns the variable attribute.
: () -> (InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode)
12010 12011 12012 |
# File 'lib/prism/node.rb', line 12010 def variable @variable end |