Sha256: 977a4c4d0d76922040063bd4e8e12f1ab64fa6ba6dc458ced3f0f504162977fc

Contents?: true

Size: 805 Bytes

Versions: 6

Compression:

Stored size: 805 Bytes

Contents

module Unparser
  class Emitter
    # Emitter for for nodes
    class For < self

      handle :for

      children :condition, :assignment, :body

    private

      # Perform dispatch
      #
      # @return [undefined]
      #
      # @api private
      #
      def dispatch
        write(K_FOR, WS)
        emit_condition
        emit_body
        k_end
      end

      # Emit assignment
      #
      # @return [undefined]
      #
      # @api private
      #
      def emit_condition
        visit(condition)
        write(WS, K_IN, WS)
        visit(assignment)
        write(WS, K_DO)
      end

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

    end # For
  end # Emitter
end # Unparser

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
unparser-0.0.6 lib/unparser/emitter/for.rb
unparser-0.0.5 lib/unparser/emitter/for.rb
unparser-0.0.4 lib/unparser/emitter/for.rb
unparser-0.0.3 lib/unparser/emitter/for.rb
unparser-0.0.2 lib/unparser/emitter/for.rb
unparser-0.0.1 lib/unparser/emitter/for.rb