Class: YARP::PostExecutionNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::PostExecutionNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘END` keyword.
END { foo }
^^^^^^^^^^^
Instance Attribute Summary collapse
-
#closing_loc ⇒ Object
readonly
attr_reader closing_loc: Location.
-
#keyword_loc ⇒ Object
readonly
attr_reader keyword_loc: Location.
-
#opening_loc ⇒ Object
readonly
attr_reader opening_loc: Location.
-
#statements ⇒ Object
readonly
attr_reader statements: StatementsNode?.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#closing ⇒ Object
def closing: () -> String.
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#copy(**params) ⇒ Object
def copy: (**params) -> PostExecutionNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(statements, keyword_loc, opening_loc, closing_loc, location) ⇒ PostExecutionNode
constructor
def initialize: (statements: StatementsNode?, keyword_loc: Location, opening_loc: Location, closing_loc: Location, location: Location) -> void.
- #inspect(inspector = NodeInspector.new) ⇒ Object
-
#keyword ⇒ Object
def keyword: () -> String.
-
#opening ⇒ Object
def opening: () -> String.
Constructor Details
#initialize(statements, keyword_loc, opening_loc, closing_loc, location) ⇒ PostExecutionNode
def initialize: (statements: StatementsNode?, keyword_loc: Location, opening_loc: Location, closing_loc: Location, location: Location) -> void
8087 8088 8089 8090 8091 8092 8093 |
# File 'lib/yarp/node.rb', line 8087 def initialize(statements, keyword_loc, opening_loc, closing_loc, location) @statements = statements @keyword_loc = keyword_loc @opening_loc = opening_loc @closing_loc = closing_loc @location = location end |
Instance Attribute Details
#closing_loc ⇒ Object (readonly)
attr_reader closing_loc: Location
8084 8085 8086 |
# File 'lib/yarp/node.rb', line 8084 def closing_loc @closing_loc end |
#keyword_loc ⇒ Object (readonly)
attr_reader keyword_loc: Location
8078 8079 8080 |
# File 'lib/yarp/node.rb', line 8078 def keyword_loc @keyword_loc end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
8081 8082 8083 |
# File 'lib/yarp/node.rb', line 8081 def opening_loc @opening_loc end |
#statements ⇒ Object (readonly)
attr_reader statements: StatementsNode?
8075 8076 8077 |
# File 'lib/yarp/node.rb', line 8075 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
8096 8097 8098 |
# File 'lib/yarp/node.rb', line 8096 def accept(visitor) visitor.visit_post_execution_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
8101 8102 8103 |
# File 'lib/yarp/node.rb', line 8101 def child_nodes [statements] end |
#closing ⇒ Object
def closing: () -> String
8140 8141 8142 |
# File 'lib/yarp/node.rb', line 8140 def closing closing_loc.slice end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
8106 8107 8108 |
# File 'lib/yarp/node.rb', line 8106 def comment_targets [*statements, keyword_loc, opening_loc, closing_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> PostExecutionNode
8111 8112 8113 8114 8115 8116 8117 8118 8119 |
# File 'lib/yarp/node.rb', line 8111 def copy(**params) PostExecutionNode.new( params.fetch(:statements) { statements }, params.fetch(:keyword_loc) { keyword_loc }, params.fetch(:opening_loc) { opening_loc }, params.fetch(:closing_loc) { closing_loc }, params.fetch(:location) { location }, ) end |
#deconstruct_keys(keys) ⇒ Object
8125 8126 8127 |
# File 'lib/yarp/node.rb', line 8125 def deconstruct_keys(keys) { statements: statements, keyword_loc: keyword_loc, opening_loc: opening_loc, closing_loc: closing_loc, location: location } end |
#inspect(inspector = NodeInspector.new) ⇒ Object
8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 |
# File 'lib/yarp/node.rb', line 8144 def inspect(inspector = NodeInspector.new) inspector << inspector.header(self) if (statements = self.statements).nil? inspector << "├── statements: ∅\n" else inspector << "├── statements:\n" inspector << statements.inspect(inspector.child_inspector("│ ")).delete_prefix(inspector.prefix) end inspector << "├── keyword_loc: #{inspector.location(keyword_loc)}\n" inspector << "├── opening_loc: #{inspector.location(opening_loc)}\n" inspector << "└── closing_loc: #{inspector.location(closing_loc)}\n" inspector.to_str end |
#keyword ⇒ Object
def keyword: () -> String
8130 8131 8132 |
# File 'lib/yarp/node.rb', line 8130 def keyword keyword_loc.slice end |
#opening ⇒ Object
def opening: () -> String
8135 8136 8137 |
# File 'lib/yarp/node.rb', line 8135 def opening opening_loc.slice end |