Sha256: d5cf30e343280270b858bc969124bb78f05ddf6f2215c54b4c0cdf2ff40224bb

Contents?: true

Size: 1.81 KB

Versions: 6

Compression:

Stored size: 1.81 KB

Contents

# encoding: utf-8

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

      children :exception, :assignment, :body

      # Emitter for resbody in standalone form
      class Standalone < self

      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

      # Emitter for resbody in keyworkd-embedded form
      class Embedded < self

        handle :resbody

      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

6 entries across 6 versions & 1 rubygems

Version Path
unparser-0.1.15 lib/unparser/emitter/resbody.rb
unparser-0.1.14 lib/unparser/emitter/resbody.rb
unparser-0.1.13 lib/unparser/emitter/resbody.rb
unparser-0.1.12 lib/unparser/emitter/resbody.rb
unparser-0.1.11 lib/unparser/emitter/resbody.rb
unparser-0.1.10 lib/unparser/emitter/resbody.rb