Sha256: a90e46c4b3dbd170732958c9018277596d543738ece58f8542d2d9dae1a35344

Contents?: true

Size: 1.35 KB

Versions: 11

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

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, WS)
          visit_plain(body)
        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

11 entries across 11 versions & 1 rubygems

Version Path
unparser-0.4.9 lib/unparser/emitter/resbody.rb
unparser-0.4.8 lib/unparser/emitter/resbody.rb
unparser-0.4.7 lib/unparser/emitter/resbody.rb
unparser-0.4.6 lib/unparser/emitter/resbody.rb
unparser-0.4.5 lib/unparser/emitter/resbody.rb
unparser-0.4.4 lib/unparser/emitter/resbody.rb
unparser-0.4.3 lib/unparser/emitter/resbody.rb
unparser-0.4.2 lib/unparser/emitter/resbody.rb
unparser-0.4.1 lib/unparser/emitter/resbody.rb
unparser-0.4.0 lib/unparser/emitter/resbody.rb
unparser-0.3.0 lib/unparser/emitter/resbody.rb