Sha256: d89765e40c5a8006787b2fe6d0875b97f03df0d0ec484e585472c0b4eb5b5790

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

# encoding: utf-8

module Unparser
  class Emitter
    # Emitter for rescue body nodes
    class Resbody < self

        children :exception, :assignment, :body

      class Standalone < self

        handle :resbody

      private

        # Perform dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          write(K_RESCUE)
          parentheses { visit(body) }
        end

        # Emit exception
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit_exception
          return unless exception
          ws
          delimited(exception.children)
        end

        # Emit assignment
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit_assignment
          return unless assignment
          write(WS, T_ASR, WS)
          visit(assignment)
        end
      end

      class Embedded < self

      private

        # Perform dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          write(K_RESCUE)
          emit_exception
          emit_assignment
          emit_body
        end

        # Emit exception
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit_exception
          return unless exception
          ws
          delimited(exception.children)
        end

        # Emit assignment
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit_assignment
          return unless assignment
          write(WS, T_ASR, WS)
          visit(assignment)
        end

      end # Resbody
    end
  end # Emitter
end # Unparser

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unparser-0.1.7 lib/unparser/emitter/resbody.rb