Class: RubyModKit::Node::DefParentNode
- Defined in:
- lib/ruby_mod_kit/node/def_parent_node.rb
Overview
Transpiler program node
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
: Node::BaseNode.
-
#prev ⇒ Object
readonly
: Node::BaseNode | nil.
Instance Method Summary collapse
- #body_node ⇒ Node::StatementsNode?
- #initialize(prism_node, parent:, prev: nil) ⇒ void constructor
- #wrap(prism_child_node, prev: nil) ⇒ Node::BaseNode
Methods inherited from BaseNode
#ancestors, #children, #def_node_at, #def_parent_node_at, #end_offset, #include?, #inspect, #location, #name, #node_at, #offset, #parameter_node_at, #slice, #statements_node_at
Constructor Details
#initialize(prism_node, parent:, prev: nil) ⇒ void
26 27 28 29 30 31 32 33 |
# File 'lib/ruby_mod_kit/node/def_parent_node.rb', line 26 def initialize(prism_node, parent:, prev: nil) @prism_node = prism_node @parent = parent @prev = prev raise RubyModKit::Error if !prism_node.is_a?(Prism::ClassNode) && !prism_node.is_a?(Prism::ModuleNode) super() end |
Instance Attribute Details
#parent ⇒ Object (readonly)
: Node::BaseNode
15 16 17 |
# File 'lib/ruby_mod_kit/node/def_parent_node.rb', line 15 def parent @parent end |
#prev ⇒ Object (readonly)
: Node::BaseNode | nil
16 17 18 |
# File 'lib/ruby_mod_kit/node/def_parent_node.rb', line 16 def prev @prev end |
Instance Method Details
#body_node ⇒ Node::StatementsNode?
49 50 51 52 53 |
# File 'lib/ruby_mod_kit/node/def_parent_node.rb', line 49 def body_node # body_node will be set in #children children @body_node end |
#wrap(prism_child_node, prev: nil) ⇒ Node::BaseNode
41 42 43 44 45 |
# File 'lib/ruby_mod_kit/node/def_parent_node.rb', line 41 def wrap(prism_child_node, prev: nil) child_node = super @body_node = child_node if prism_child_node == @prism_node.body && child_node.is_a?(Node::StatementsNode) child_node end |