Class: YARP::RestParameterNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::RestParameterNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a rest parameter to a method, block, or lambda definition.
def a(*b)
^^
end
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
attr_reader name: Symbol?.
-
#name_loc ⇒ Object
readonly
attr_reader name_loc: Location?.
-
#operator_loc ⇒ Object
readonly
attr_reader operator_loc: Location.
Instance Method Summary collapse
-
#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].
-
#copy(**params) ⇒ Object
def copy: (**params) -> RestParameterNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, name_loc, operator_loc, location) ⇒ RestParameterNode
constructor
def initialize: (name: Symbol?, name_loc: Location?, operator_loc: Location, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#operator ⇒ Object
def operator: () -> String.
Constructor Details
#initialize(name, name_loc, operator_loc, location) ⇒ RestParameterNode
def initialize: (name: Symbol?, name_loc: Location?, operator_loc: Location, location: Location) -> void
8960 8961 8962 8963 8964 8965 |
# File 'lib/yarp/node.rb', line 8960 def initialize(name, name_loc, operator_loc, location) @name = name @name_loc = name_loc @operator_loc = operator_loc @location = location end |
Instance Attribute Details
#name ⇒ Object (readonly)
attr_reader name: Symbol?
8951 8952 8953 |
# File 'lib/yarp/node.rb', line 8951 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location?
8954 8955 8956 |
# File 'lib/yarp/node.rb', line 8954 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
8957 8958 8959 |
# File 'lib/yarp/node.rb', line 8957 def operator_loc @operator_loc end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
8968 8969 8970 |
# File 'lib/yarp/node.rb', line 8968 def accept(visitor) visitor.visit_rest_parameter_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
8973 8974 8975 |
# File 'lib/yarp/node.rb', line 8973 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
8978 8979 8980 |
# File 'lib/yarp/node.rb', line 8978 def comment_targets [*name_loc, operator_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> RestParameterNode
8983 8984 8985 8986 8987 8988 8989 8990 |
# File 'lib/yarp/node.rb', line 8983 def copy(**params) RestParameterNode.new( params.fetch(:name) { name }, params.fetch(:name_loc) { name_loc }, params.fetch(:operator_loc) { operator_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
8996 8997 8998 |
# File 'lib/yarp/node.rb', line 8996 def deconstruct_keys(keys) { name: name, name_loc: name_loc, operator_loc: operator_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
9005 9006 9007 9008 9009 9010 9011 |
# File 'lib/yarp/node.rb', line 9005 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) inspector << "├── name: #{name.inspect}\n" inspector << "├── name_loc: #{inspector.location(name_loc)}\n" inspector << "└── operator_loc: #{inspector.location(operator_loc)}\n" inspector.to_str end |
#operator ⇒ Object
def operator: () -> String
9001 9002 9003 |
# File 'lib/yarp/node.rb', line 9001 def operator operator_loc.slice end |