Sha256: 977e168fce68baca9ae275386054074b2ad87f036c37247eb4e9535736f2f86e

Contents?: true

Size: 858 Bytes

Versions: 2

Compression:

Stored size: 858 Bytes

Contents

module Unparser
  class Emitter

    # Block emitter
    class Block < self

      handle :block

      children :send, :arguments, :body

    private

      # Perform dispatch
      #
      # @return [undefined]
      #
      # @api private
      #
      def dispatch
        visit(send)
        write(WS, K_DO)
        emit_block_arguments
        indented { emit_body }
        k_end
      end

      # Emit arguments
      #
      # @return [undefined]
      #
      # @api private
      #
      def emit_block_arguments
        return if arguments.children.empty?
        ws
        parentheses(O_PIPE, O_PIPE) do
          visit(arguments)
        end
      end

      # Emit body
      #
      # @return [undefined]
      #
      # @api private
      #
      def emit_body
        visit(body)
      end

    end # Block
  end # Emitter
end # Unparser

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unparser-0.0.2 lib/unparser/emitter/block.rb
unparser-0.0.1 lib/unparser/emitter/block.rb