Sha256: 0170b198593d564c46b2308969b422a569be04ce12bdef7e2b5c5cb5d4ec4e50

Contents?: true

Size: 725 Bytes

Versions: 8

Compression:

Stored size: 725 Bytes

Contents

module Zapata
  module Primitive
    class Base
      attr_accessor :code, :type

      def initialize(code)
        @code = code
        @type = code.type
      end

      def name
        SaveManager.clean(node.name)
      end

      def dive_deeper
        unless RETURN_TYPES.include?(node.type)
          Diver.dive(node.args)
          Diver.dive(node.body)
        end
      end

      def to_raw
        Diver.dive(node.body).to_raw
      end

      def return_with_super_as_missing(raw, primitive)
        raw.type == :super ? Missing.new(primitive.name).to_raw : raw
      end

      def return_with_missing_as_super(raw, name)
        raw.type == :missing ? Raw.new(:super, name) : raw
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
zapata-0.1.6 lib/zapata/primitive/base.rb
zapata-0.1.5 lib/zapata/primitive/base.rb
zapata-0.1.4 lib/zapata/primitive/base.rb
zapata-0.1.3 lib/zapata/primitive/base.rb
zapata-0.1.2 lib/zapata/primitive/base.rb
zapata-0.1.1 lib/zapata/primitive/base.rb
zapata-0.1.0 lib/zapata/primitive/base.rb
zapata-0.0.3 lib/zapata/primitive/base.rb