Class: YARP::ForNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ForNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘for` keyword.
for i in a end
^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
attr_reader collection: Node.
-
#do_keyword_loc ⇒ Object
readonly
attr_reader do_keyword_loc: Location?.
-
#end_keyword_loc ⇒ Object
readonly
attr_reader end_keyword_loc: Location.
-
#for_keyword_loc ⇒ Object
readonly
attr_reader for_keyword_loc: Location.
-
#in_keyword_loc ⇒ Object
readonly
attr_reader in_keyword_loc: Location.
-
#index ⇒ Object
readonly
attr_reader index: Node.
-
#statements ⇒ Object
readonly
attr_reader statements: Node?.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
- #deconstruct_keys(keys) ⇒ Object
-
#do_keyword ⇒ Object
def do_keyword: () -> String?.
-
#end_keyword ⇒ Object
def end_keyword: () -> String.
-
#for_keyword ⇒ Object
def for_keyword: () -> String.
-
#in_keyword ⇒ Object
def in_keyword: () -> String.
-
#initialize(index, collection, statements, for_keyword_loc, in_keyword_loc, do_keyword_loc, end_keyword_loc, location) ⇒ ForNode
constructor
def initialize: (index: Node, collection: Node, statements: Node?, for_keyword_loc: Location, in_keyword_loc: Location, do_keyword_loc: Location?, end_keyword_loc: Location, location: Location) -> void.
Constructor Details
#initialize(index, collection, statements, for_keyword_loc, in_keyword_loc, do_keyword_loc, end_keyword_loc, location) ⇒ ForNode
def initialize: (index: Node, collection: Node, statements: Node?, for_keyword_loc: Location, in_keyword_loc: Location, do_keyword_loc: Location?, end_keyword_loc: Location, location: Location) -> void
2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 |
# File 'lib/yarp/node.rb', line 2430 def initialize(index, collection, statements, for_keyword_loc, in_keyword_loc, do_keyword_loc, end_keyword_loc, location) @index = index @collection = collection @statements = statements @for_keyword_loc = for_keyword_loc @in_keyword_loc = in_keyword_loc @do_keyword_loc = do_keyword_loc @end_keyword_loc = end_keyword_loc @location = location end |
Instance Attribute Details
#collection ⇒ Object (readonly)
attr_reader collection: Node
2412 2413 2414 |
# File 'lib/yarp/node.rb', line 2412 def collection @collection end |
#do_keyword_loc ⇒ Object (readonly)
attr_reader do_keyword_loc: Location?
2424 2425 2426 |
# File 'lib/yarp/node.rb', line 2424 def do_keyword_loc @do_keyword_loc end |
#end_keyword_loc ⇒ Object (readonly)
attr_reader end_keyword_loc: Location
2427 2428 2429 |
# File 'lib/yarp/node.rb', line 2427 def end_keyword_loc @end_keyword_loc end |
#for_keyword_loc ⇒ Object (readonly)
attr_reader for_keyword_loc: Location
2418 2419 2420 |
# File 'lib/yarp/node.rb', line 2418 def for_keyword_loc @for_keyword_loc end |
#in_keyword_loc ⇒ Object (readonly)
attr_reader in_keyword_loc: Location
2421 2422 2423 |
# File 'lib/yarp/node.rb', line 2421 def in_keyword_loc @in_keyword_loc end |
#index ⇒ Object (readonly)
attr_reader index: Node
2409 2410 2411 |
# File 'lib/yarp/node.rb', line 2409 def index @index end |
#statements ⇒ Object (readonly)
attr_reader statements: Node?
2415 2416 2417 |
# File 'lib/yarp/node.rb', line 2415 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
2442 2443 2444 |
# File 'lib/yarp/node.rb', line 2442 def accept(visitor) visitor.visit_for_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2448 2449 2450 |
# File 'lib/yarp/node.rb', line 2448 def child_nodes [index, collection, statements] end |
#deconstruct_keys(keys) ⇒ Object
2456 2457 2458 |
# File 'lib/yarp/node.rb', line 2456 def deconstruct_keys(keys) { index: index, collection: collection, statements: statements, for_keyword_loc: for_keyword_loc, in_keyword_loc: in_keyword_loc, do_keyword_loc: do_keyword_loc, end_keyword_loc: end_keyword_loc, location: location } end |
#do_keyword ⇒ Object
def do_keyword: () -> String?
2471 2472 2473 |
# File 'lib/yarp/node.rb', line 2471 def do_keyword do_keyword_loc&.slice end |
#end_keyword ⇒ Object
def end_keyword: () -> String
2476 2477 2478 |
# File 'lib/yarp/node.rb', line 2476 def end_keyword end_keyword_loc.slice end |
#for_keyword ⇒ Object
def for_keyword: () -> String
2461 2462 2463 |
# File 'lib/yarp/node.rb', line 2461 def for_keyword for_keyword_loc.slice end |
#in_keyword ⇒ Object
def in_keyword: () -> String
2466 2467 2468 |
# File 'lib/yarp/node.rb', line 2466 def in_keyword in_keyword_loc.slice end |