Sha256: c39db946fd4dace2c255744de5755750711fd8cf954e002d4febb2ea84a961f1

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

# encoding: utf-8

module Unparser
  class Emitter
    # Emitter for class nodes
    class Class < self
      include LocalVariableRoot, Terminated

      handle :class

      children :name, :superclass, :body

    private

      # Perform dispatch
      #
      # @return [undefined]
      #
      # @api private
      #
      def dispatch
        write(K_CLASS, WS)
        visit(name)
        emit_superclass
        emit_body
        k_end
      end

      # Emit superclass
      #
      # @return [undefined]
      #
      # @api private
      #
      def emit_superclass
        return unless superclass
        write(WS, T_LT, WS)
        visit(superclass)
      end

    end # Class

    # Emitter for sclass nodes
    class SClass  < self
      include Terminated

      handle :sclass

      children :object, :body

    private

      # Perform dispatch
      #
      # @return [undefined]
      #
      # @api private
      #
      def dispatch
        write(K_CLASS, WS, T_DLT, WS)
        visit(object)
        emit_body
        k_end
      end

    end # SClass
  end # Emitter
end # Unparser

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
unparser-0.2.4 lib/unparser/emitter/class.rb
unparser-0.2.3 lib/unparser/emitter/class.rb
unparser-0.2.2 lib/unparser/emitter/class.rb
unparser-0.2.1 lib/unparser/emitter/class.rb
unparser-0.2.0 lib/unparser/emitter/class.rb
unparser-0.1.16 lib/unparser/emitter/class.rb