Class: Prism::EmbeddedVariableNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::EmbeddedVariableNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents an interpolated variable.
"foo #@bar"
^^^^^
Instance Attribute Summary collapse
-
#variable ⇒ Object
readonly
attr_reader variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array.
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, operator_loc: self.operator_loc, variable: self.variable) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) -> EmbeddedVariableNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, operator_loc: Location, variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode }.
-
#initialize(source, node_id, location, flags, operator_loc, variable) ⇒ EmbeddedVariableNode
constructor
Initialize a new EmbeddedVariableNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#operator ⇒ Object
def operator: () -> String.
-
#operator_loc ⇒ Object
attr_reader operator_loc: Location.
-
#save_operator_loc(repository) ⇒ Object
Save the operator_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, operator_loc, variable) ⇒ EmbeddedVariableNode
Initialize a new EmbeddedVariableNode node.
6562 6563 6564 6565 6566 6567 6568 6569 |
# File 'lib/prism/node.rb', line 6562 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 |
Instance Attribute Details
#variable ⇒ Object (readonly)
attr_reader variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode
6618 6619 6620 |
# File 'lib/prism/node.rb', line 6618 def variable @variable end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
6636 6637 6638 |
# File 'lib/prism/node.rb', line 6636 def self.type :embedded_variable_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
6642 6643 6644 6645 6646 |
# File 'lib/prism/node.rb', line 6642 def ===(other) other.is_a?(EmbeddedVariableNode) && (operator_loc.nil? == other.operator_loc.nil?) && (variable === other.variable) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
6572 6573 6574 |
# File 'lib/prism/node.rb', line 6572 def accept(visitor) visitor.(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
6577 6578 6579 |
# File 'lib/prism/node.rb', line 6577 def child_nodes [variable] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
6587 6588 6589 |
# File 'lib/prism/node.rb', line 6587 def comment_targets [operator_loc, variable] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
6582 6583 6584 |
# File 'lib/prism/node.rb', line 6582 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) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode) -> EmbeddedVariableNode
6592 6593 6594 |
# File 'lib/prism/node.rb', line 6592 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) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, operator_loc: Location, variable: InstanceVariableReadNode | ClassVariableReadNode | GlobalVariableReadNode | BackReferenceReadNode | NumberedReferenceReadNode }
6600 6601 6602 |
# File 'lib/prism/node.rb', line 6600 def deconstruct_keys(keys) { node_id: node_id, location: location, operator_loc: operator_loc, variable: variable } end |
#inspect ⇒ Object
def inspect -> String
6626 6627 6628 |
# File 'lib/prism/node.rb', line 6626 def inspect InspectVisitor.compose(self) end |
#operator ⇒ Object
def operator: () -> String
6621 6622 6623 |
# File 'lib/prism/node.rb', line 6621 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
6605 6606 6607 6608 6609 |
# File 'lib/prism/node.rb', line 6605 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) ⇒ Object
Save the operator_loc location using the given saved source so that it can be retrieved later.
6613 6614 6615 |
# File 'lib/prism/node.rb', line 6613 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
6631 6632 6633 |
# File 'lib/prism/node.rb', line 6631 def type :embedded_variable_node end |