Sha256: 5b1935db7b34ae115ce679313f6a9fe956ef87ced5ace3a8298de799b85d8095

Contents?: true

Size: 850 Bytes

Versions: 14

Compression:

Stored size: 850 Bytes

Contents

module Unparser
  class Emitter
    # Base class for binary emitters
    class Binary < self

      handle :or, :and
      children :left, :right

      MAP = {
        :or => T_OR,
        :and => T_AND
      }.freeze

    private

      # Perform dispatch
      #
      # @return [undefined]
      #
      # @api private
      #
      def dispatch
        parentheses do
          emit_left
          write(WS, MAP.fetch(node.type), WS)
          emit_right
        end
      end

      # Emit left
      #
      # @return [undefined]
      #
      # @api private
      #
      def emit_left
        parentheses { visit(left) }
      end

      # Emit right
      #
      # @return [undefined]
      #
      # @api private
      #
      def emit_right
        parentheses { visit(right) }
      end

    end # Binary
  end # Emitter
end # Unparser

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
unparser-0.0.18 lib/unparser/emitter/binary.rb
unparser-0.0.16 lib/unparser/emitter/binary.rb
unparser-0.0.15 lib/unparser/emitter/binary.rb
unparser-0.0.14 lib/unparser/emitter/binary.rb
unparser-0.0.13 lib/unparser/emitter/binary.rb
unparser-0.0.12 lib/unparser/emitter/binary.rb
unparser-0.0.11 lib/unparser/emitter/binary.rb
unparser-0.0.10 lib/unparser/emitter/binary.rb
unparser-0.0.8 lib/unparser/emitter/binary.rb
unparser-0.0.7 lib/unparser/emitter/binary.rb
unparser-0.0.6 lib/unparser/emitter/binary.rb
unparser-0.0.5 lib/unparser/emitter/binary.rb
unparser-0.0.4 lib/unparser/emitter/binary.rb
unparser-0.0.3 lib/unparser/emitter/binary.rb