Class: Prism::KeywordRestParameterNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::KeywordRestParameterNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents a keyword rest parameter to a method, block, or lambda definition.
def a(**b)
^^^
end
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
attr_reader name: Symbol?.
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[nil | Node].
-
#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, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> KeywordRestParameterNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol?, name_loc: Location?, operator_loc: Location }.
-
#initialize(source, node_id, location, flags, name, name_loc, operator_loc) ⇒ KeywordRestParameterNode
constructor
Initialize a new KeywordRestParameterNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#name_loc ⇒ Object
attr_reader name_loc: Location?.
-
#operator ⇒ Object
def operator: () -> String.
-
#operator_loc ⇒ Object
attr_reader operator_loc: Location.
-
#repeated_parameter? ⇒ Boolean
def repeated_parameter?: () -> bool.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, name, name_loc, operator_loc) ⇒ KeywordRestParameterNode
Initialize a new KeywordRestParameterNode node.
10192 10193 10194 10195 10196 10197 10198 10199 10200 |
# File 'lib/prism/node.rb', line 10192 def initialize(source, node_id, location, flags, name, name_loc, operator_loc) @source = source @node_id = node_id @location = location @flags = flags @name = name @name_loc = name_loc @operator_loc = operator_loc end |
Instance Attribute Details
#name ⇒ Object (readonly)
attr_reader name: Symbol?
10241 10242 10243 |
# File 'lib/prism/node.rb', line 10241 def name @name end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
10279 10280 10281 |
# File 'lib/prism/node.rb', line 10279 def self.type :keyword_rest_parameter_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.
10285 10286 10287 10288 10289 10290 10291 |
# File 'lib/prism/node.rb', line 10285 def ===(other) other.is_a?(KeywordRestParameterNode) && (flags === other.flags) && (name === other.name) && (name_loc.nil? == other.name_loc.nil?) && (operator_loc.nil? == other.operator_loc.nil?) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
10203 10204 10205 |
# File 'lib/prism/node.rb', line 10203 def accept(visitor) visitor.visit_keyword_rest_parameter_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
10208 10209 10210 |
# File 'lib/prism/node.rb', line 10208 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
10218 10219 10220 |
# File 'lib/prism/node.rb', line 10218 def comment_targets [*name_loc, operator_loc] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
10213 10214 10215 |
# File 'lib/prism/node.rb', line 10213 def compact_child_nodes [] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol?, ?name_loc: Location?, ?operator_loc: Location) -> KeywordRestParameterNode
10223 10224 10225 |
# File 'lib/prism/node.rb', line 10223 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc) KeywordRestParameterNode.new(source, node_id, location, flags, name, name_loc, operator_loc) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol?, name_loc: Location?, operator_loc: Location }
10231 10232 10233 |
# File 'lib/prism/node.rb', line 10231 def deconstruct_keys(keys) { node_id: node_id, location: location, name: name, name_loc: name_loc, operator_loc: operator_loc } end |
#inspect ⇒ Object
def inspect -> String
10269 10270 10271 |
# File 'lib/prism/node.rb', line 10269 def inspect InspectVisitor.compose(self) end |
#name_loc ⇒ Object
attr_reader name_loc: Location?
10244 10245 10246 10247 10248 10249 10250 10251 10252 10253 10254 |
# File 'lib/prism/node.rb', line 10244 def name_loc location = @name_loc case location when nil nil when Location location else @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end end |
#operator ⇒ Object
def operator: () -> String
10264 10265 10266 |
# File 'lib/prism/node.rb', line 10264 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
10257 10258 10259 10260 10261 |
# File 'lib/prism/node.rb', line 10257 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#repeated_parameter? ⇒ Boolean
def repeated_parameter?: () -> bool
10236 10237 10238 |
# File 'lib/prism/node.rb', line 10236 def repeated_parameter? flags.anybits?(ParameterFlags::REPEATED_PARAMETER) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
10274 10275 10276 |
# File 'lib/prism/node.rb', line 10274 def type :keyword_rest_parameter_node end |