Class: Prettyrb::Nodes::BaseNode

Inherits:
Parser::AST::Node
  • Object
show all
Defined in:
lib/prettyrb/nodes/base_node.rb

Direct Known Subclasses

AndNode, DefNode, DstrNode, IfNode, OrNode, RegexpNode, SendNode, StrNode

Instance Method Summary collapse

Constructor Details

#initialize(type, children, properties) ⇒ BaseNode

Returns a new instance of BaseNode.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/prettyrb/nodes/base_node.rb', line 6

def initialize(type, children, properties)
  @mutable = {}

  super

  children&.each do |child|
    next unless child.is_a?(BaseNode)
    child.parent = self
  end

  self
end

Instance Method Details

#parentObject



19
20
21
# File 'lib/prettyrb/nodes/base_node.rb', line 19

def parent
  @mutable[:parent]
end

#string?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/prettyrb/nodes/base_node.rb', line 23

def string?
  type == :str || type == :dstr
end