Sha256: d00d752dbfa2e0be40f92d58dca96bdf37f96310abf9e86a16f7f8f82de04afb

Contents?: true

Size: 549 Bytes

Versions: 1

Compression:

Stored size: 549 Bytes

Contents

require "delegate"

module Prettyrb
  module Nodes
    class BaseNode < Parser::AST::Node
      def initialize(type, children, properties)
        @mutable = {}

        super

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

        self
      end

      def parent
        @mutable[:parent]
      end

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

      protected

      def parent=(parent)
        @mutable[:parent] = parent
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prettyrb-0.5.0 lib/prettyrb/nodes/base_node.rb