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 }.
-
#each_child_node {|variable| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator.
-
#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.
6969 6970 6971 6972 6973 6974 6975 6976 |
# File 'lib/prism/node.rb', line 6969 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
7032 7033 7034 |
# File 'lib/prism/node.rb', line 7032 def variable @variable end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See Node::type.
7050 7051 7052 |
# File 'lib/prism/node.rb', line 7050 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.
7056 7057 7058 7059 7060 |
# File 'lib/prism/node.rb', line 7056 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
6979 6980 6981 |
# File 'lib/prism/node.rb', line 6979 def accept(visitor) visitor.(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
6984 6985 6986 |
# File 'lib/prism/node.rb', line 6984 def child_nodes [variable] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
7001 7002 7003 |
# File 'lib/prism/node.rb', line 7001 def comment_targets [operator_loc, variable] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
6996 6997 6998 |
# File 'lib/prism/node.rb', line 6996 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
7006 7007 7008 |
# File 'lib/prism/node.rb', line 7006 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 }
7014 7015 7016 |
# File 'lib/prism/node.rb', line 7014 def deconstruct_keys(keys) { node_id: node_id, location: location, operator_loc: operator_loc, variable: variable } end |
#each_child_node {|variable| ... } ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator
6989 6990 6991 6992 6993 |
# File 'lib/prism/node.rb', line 6989 def each_child_node return to_enum(:each_child_node) unless block_given? yield variable end |
#inspect ⇒ Object
def inspect -> String
7040 7041 7042 |
# File 'lib/prism/node.rb', line 7040 def inspect InspectVisitor.compose(self) end |
#operator ⇒ Object
def operator: () -> String
7035 7036 7037 |
# File 'lib/prism/node.rb', line 7035 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
7019 7020 7021 7022 7023 |
# File 'lib/prism/node.rb', line 7019 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.
7027 7028 7029 |
# File 'lib/prism/node.rb', line 7027 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`.
7045 7046 7047 |
# File 'lib/prism/node.rb', line 7045 def type :embedded_variable_node end |