Sha256: 3f3257157dfff99954e37faf700e8ca271d40c1401aa75437c7b7547dd6e6772

Contents?: true

Size: 675 Bytes

Versions: 11

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true

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

      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.equal?(:int) && selector.equal?(:'+@')
            write('+')
          end

          visit(receiver)
        end

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

Version data entries

11 entries across 11 versions & 1 rubygems

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