Class: Prism::NumberedParametersNode

Inherits:
PrismNode
  • Object
show all
Defined in:
lib/prism/node.rb,
sig/generated/prism/node.rbs,
ext/prism/api_node.c

Overview

Represents an implicit set of parameters through the use of numbered parameters within a block or lambda.

-> { _1 + _2 }
^^^^^^^^^^^^^^

Explore code sample

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, maximum) ⇒ NumberedParametersNode

Initialize a new NumberedParametersNode node.

: (Source source, Integer node_id, Location location, Integer flags, Integer maximum) -> void

Parameters:

  • source (Source)
  • node_id (Integer)
  • location (Location)
  • flags (Integer)
  • maximum (Integer)


25195
25196
25197
25198
25199
25200
25201
# File 'lib/prism/node.rb', line 25195

def initialize(source, node_id, location, flags, maximum)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @maximum = maximum
end

Class Method Details

.type ⇒ :numbered_parameters_node

See Node.type.

: () -> :numbered_parameters_node

Returns:

  • (:numbered_parameters_node)


25279
25280
25281
# File 'lib/prism/node.rb', line 25279

def self.type
  :numbered_parameters_node
end

Instance Method Details

#===(other) ⇒ boolish

: (untyped other) -> boolish

Parameters:

  • other (Object)

Returns:

  • (boolish)


25305
25306
25307
25308
# File 'lib/prism/node.rb', line 25305

def ===(other) # :nodoc:
  other.is_a?(NumberedParametersNode) &&
    (maximum === other.maximum)
end

#accept(visitor) ⇒ Object

See Node.accept.

: (_Visitor visitor) -> untyped

Parameters:

Returns:

  • (Object)


25217
25218
25219
# File 'lib/prism/node.rb', line 25217

def accept(visitor)
  visitor.visit_numbered_parameters_node(self)
end

#child_nodes ⇒ Array[node?] Also known as: deconstruct

See Node.child_nodes.

: () -> Array

Returns:

  • (Array[node?])


25224
25225
25226
# File 'lib/prism/node.rb', line 25224

def child_nodes
  []
end

#compact_child_nodes ⇒ Array[node]

See Node.compact_child_nodes.

: () -> Array

Returns:

  • (Array[node])


25240
25241
25242
# File 'lib/prism/node.rb', line 25240

def compact_child_nodes
  []
end

#copy(node_id: self.node_id, location: self.location, flags: self.flags, maximum: self.maximum) ⇒ NumberedParametersNode

:call-seq:

copy(**fields) -> NumberedParametersNode

Creates a copy of self with the given fields, using self as the template.

: (?node_id: Integer, ?location: Location, ?flags: Integer, ?maximum: Integer) -> NumberedParametersNode

Parameters:

  • node_id: (Integer) (defaults to: self.node_id)
  • location: (Location) (defaults to: self.location)
  • flags: (Integer) (defaults to: self.flags)
  • maximum: (Integer) (defaults to: self.maximum)

Returns:



25250
25251
25252
# File 'lib/prism/node.rb', line 25250

def copy(node_id: self.node_id, location: self.location, flags: self.flags, maximum: self.maximum)
  NumberedParametersNode.new(source, node_id, location, flags, maximum)
end

#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]

: (Array? keys) -> Hash[Symbol, untyped]

Parameters:

  • keys (Array[Symbol], nil)

Returns:

  • (Hash[Symbol, untyped])


25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
# File 'lib/prism/node.rb', line 25257

def deconstruct_keys(keys) # :nodoc:
  (keys || %i[node_id location maximum]).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 :maximum                 then deconstructed[:maximum] = self.maximum
    end
  end
end

#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void

See Node.each_child_node.

: () -> Enumerator[node, void] : () { (node) -> void } -> void

Overloads:

  • #each_child_node ⇒ Enumerator[node, void]

    Returns:

    • (Enumerator[node, void])
  • #each_child_node ⇒ void

    This method returns an undefined value.

Yields:

Yield Parameters:

  • arg0 (node)

Yield Returns:

  • (void)


25232
25233
25234
25235
# File 'lib/prism/node.rb', line 25232

def each_child_node(&blk)
  return to_enum(:each_child_node) unless block_given?

end

#inspect ⇒ String

: () -> String

Returns:

  • (String)


25284
25285
25286
# File 'lib/prism/node.rb', line 25284

def inspect # :nodoc:
  InspectVisitor.compose(self)
end

#maximum ⇒ Integer

:call-seq:

maximum -> Integer

Returns the maximum attribute.

: () -> Integer

Returns:

  • (Integer)


25296
25297
25298
# File 'lib/prism/node.rb', line 25296

def maximum
  @maximum
end

#type ⇒ :numbered_parameters_node

See Node#type.

: () -> :numbered_parameters_node

Returns:

  • (:numbered_parameters_node)


25272
25273
25274
# File 'lib/prism/node.rb', line 25272

def type
  :numbered_parameters_node
end