Class: YARP::BlockParameterNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::BlockParameterNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents a block 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) -> BlockParameterNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(name, name_loc, operator_loc, location) ⇒ BlockParameterNode
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) ⇒ BlockParameterNode
def initialize: (name: Symbol?, name_loc: Location?, operator_loc: Location, location: Location) -> void
1002 1003 1004 1005 1006 1007 |
# File 'lib/yarp/node.rb', line 1002 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?
993 994 995 |
# File 'lib/yarp/node.rb', line 993 def name @name end |
#name_loc ⇒ Object (readonly)
attr_reader name_loc: Location?
996 997 998 |
# File 'lib/yarp/node.rb', line 996 def name_loc @name_loc end |
#operator_loc ⇒ Object (readonly)
attr_reader operator_loc: Location
999 1000 1001 |
# File 'lib/yarp/node.rb', line 999 def operator_loc @operator_loc end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
1010 1011 1012 |
# File 'lib/yarp/node.rb', line 1010 def accept(visitor) visitor.visit_block_parameter_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
1015 1016 1017 |
# File 'lib/yarp/node.rb', line 1015 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
1020 1021 1022 |
# File 'lib/yarp/node.rb', line 1020 def comment_targets [*name_loc, operator_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> BlockParameterNode
1025 1026 1027 1028 1029 1030 1031 1032 |
# File 'lib/yarp/node.rb', line 1025 def copy(**params) BlockParameterNode.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
1038 1039 1040 |
# File 'lib/yarp/node.rb', line 1038 def deconstruct_keys(keys) { name: name, name_loc: name_loc, operator_loc: operator_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
1047 1048 1049 1050 1051 1052 1053 |
# File 'lib/yarp/node.rb', line 1047 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
1043 1044 1045 |
# File 'lib/yarp/node.rb', line 1043 def operator operator_loc.slice end |