Class: YARP::PreExecutionNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::PreExecutionNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
Represents the use of the ‘BEGIN` keyword.
BEGIN { 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) -> PreExecutionNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(statements, keyword_loc, opening_loc, closing_loc, location) ⇒ PreExecutionNode
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) ⇒ PreExecutionNode
def initialize: (statements: StatementsNode?, keyword_loc: Location, opening_loc: Location, closing_loc: Location, location: Location) -> void
8177 8178 8179 8180 8181 8182 8183 |
# File 'lib/yarp/node.rb', line 8177 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
8174 8175 8176 |
# File 'lib/yarp/node.rb', line 8174 def closing_loc @closing_loc end |
#keyword_loc ⇒ Object (readonly)
attr_reader keyword_loc: Location
8168 8169 8170 |
# File 'lib/yarp/node.rb', line 8168 def keyword_loc @keyword_loc end |
#opening_loc ⇒ Object (readonly)
attr_reader opening_loc: Location
8171 8172 8173 |
# File 'lib/yarp/node.rb', line 8171 def opening_loc @opening_loc end |
#statements ⇒ Object (readonly)
attr_reader statements: StatementsNode?
8165 8166 8167 |
# File 'lib/yarp/node.rb', line 8165 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
8186 8187 8188 |
# File 'lib/yarp/node.rb', line 8186 def accept(visitor) visitor.visit_pre_execution_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
8191 8192 8193 |
# File 'lib/yarp/node.rb', line 8191 def child_nodes [statements] end |
#closing ⇒ Object
def closing: () -> String
8230 8231 8232 |
# File 'lib/yarp/node.rb', line 8230 def closing closing_loc.slice end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
8196 8197 8198 |
# File 'lib/yarp/node.rb', line 8196 def comment_targets [*statements, keyword_loc, opening_loc, closing_loc] end |
#copy(**params) ⇒ Object
def copy: (**params) -> PreExecutionNode
8201 8202 8203 8204 8205 8206 8207 8208 8209 |
# File 'lib/yarp/node.rb', line 8201 def copy(**params) PreExecutionNode.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
8215 8216 8217 |
# File 'lib/yarp/node.rb', line 8215 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
8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 |
# File 'lib/yarp/node.rb', line 8234 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
8220 8221 8222 |
# File 'lib/yarp/node.rb', line 8220 def keyword keyword_loc.slice end |
#opening ⇒ Object
def opening: () -> String
8225 8226 8227 |
# File 'lib/yarp/node.rb', line 8225 def opening opening_loc.slice end |