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
2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 |
# File 'lib/yarp/node.rb', line 2450 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
2432 2433 2434 |
# File 'lib/yarp/node.rb', line 2432 def collection @collection end |
#do_keyword_loc ⇒ Object (readonly)
attr_reader do_keyword_loc: Location?
2444 2445 2446 |
# File 'lib/yarp/node.rb', line 2444 def do_keyword_loc @do_keyword_loc end |
#end_keyword_loc ⇒ Object (readonly)
attr_reader end_keyword_loc: Location
2447 2448 2449 |
# File 'lib/yarp/node.rb', line 2447 def end_keyword_loc @end_keyword_loc end |
#for_keyword_loc ⇒ Object (readonly)
attr_reader for_keyword_loc: Location
2438 2439 2440 |
# File 'lib/yarp/node.rb', line 2438 def for_keyword_loc @for_keyword_loc end |
#in_keyword_loc ⇒ Object (readonly)
attr_reader in_keyword_loc: Location
2441 2442 2443 |
# File 'lib/yarp/node.rb', line 2441 def in_keyword_loc @in_keyword_loc end |
#index ⇒ Object (readonly)
attr_reader index: Node
2429 2430 2431 |
# File 'lib/yarp/node.rb', line 2429 def index @index end |
#statements ⇒ Object (readonly)
attr_reader statements: Node?
2435 2436 2437 |
# File 'lib/yarp/node.rb', line 2435 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
2462 2463 2464 |
# File 'lib/yarp/node.rb', line 2462 def accept(visitor) visitor.visit_for_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
2467 2468 2469 |
# File 'lib/yarp/node.rb', line 2467 def child_nodes [index, collection, statements] end |
#deconstruct_keys(keys) ⇒ Object
2475 2476 2477 |
# File 'lib/yarp/node.rb', line 2475 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?
2490 2491 2492 |
# File 'lib/yarp/node.rb', line 2490 def do_keyword do_keyword_loc&.slice end |
#end_keyword ⇒ Object
def end_keyword: () -> String
2495 2496 2497 |
# File 'lib/yarp/node.rb', line 2495 def end_keyword end_keyword_loc.slice end |
#for_keyword ⇒ Object
def for_keyword: () -> String
2480 2481 2482 |
# File 'lib/yarp/node.rb', line 2480 def for_keyword for_keyword_loc.slice end |
#in_keyword ⇒ Object
def in_keyword: () -> String
2485 2486 2487 |
# File 'lib/yarp/node.rb', line 2485 def in_keyword in_keyword_loc.slice end |