Sha256: 69a4d74c373a54c96c6c18f55dd4be75b88726875b5b6247dcfdb02ea10a351a

Contents?: true

Size: 672 Bytes

Versions: 7

Compression:

Stored size: 672 Bytes

Contents

# encoding: utf-8

module Unparser
  class Emitter
    class Send
      # Emitter for unary sends
      class Unary < self

      private

        MAP = IceNine.deep_freeze(
          :'-@' => '-',
          :'+@' => '+'
        )

        # Perform dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          name = selector
          write(MAP.fetch(name, name).to_s)
          if receiver.type == :int && selector == :'+@' && receiver.children.first > 0
            write('+')
          end

          visit_terminated(receiver)
        end

      end # Unary
    end # Send
  end # Emitter
end # Unparser

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
unparser-0.1.14 lib/unparser/emitter/send/unary.rb
unparser-0.1.13 lib/unparser/emitter/send/unary.rb
unparser-0.1.12 lib/unparser/emitter/send/unary.rb
unparser-0.1.11 lib/unparser/emitter/send/unary.rb
unparser-0.1.10 lib/unparser/emitter/send/unary.rb
unparser-0.1.9 lib/unparser/emitter/send/unary.rb
unparser-0.1.8 lib/unparser/emitter/send/unary.rb