Sha256: 6b8c447cc9daf170011df5dec74751a27a874d3e942bc3b080e4c58dd339e4d4

Contents?: true

Size: 1.47 KB

Versions: 5

Compression:

Stored size: 1.47 KB

Contents

module ToSource
  class Emitter
    # Emitter for arguments node
    class ActualArguments < self

      handle(Rubinius::AST::ActualArguments)

      # Test if any arguments are present
      #
      # @return [true]
      #   if any argument is present
      #
      # @return [false]
      #   otherwise
      #
      # @api private
      #
      def any?
        normal? || splat?
      end

    private

      # Perform dispatch
      #
      # @return [self]
      #
      # @api private
      #
      def dispatch
        emit_normal
        emit_splat
      end

      delegate :array, :splat

      # Test for splat argument
      #
      # @return [true]
      #   if splate argument is present
      #
      # @return [false]
      #   otherwise
      #
      # @api private
      #
      def splat?
        !!splat
      end

      # Test if normal arguments are present
      #
      # @return [true]
      #   if normal arguments are present
      #
      # @return [false]
      #   otherwise
      #
      # @api private
      #
      def normal?
        !array.empty?
      end

      # Emit normal arguments
      #
      # @return [undefined]
      #
      # @api private
      #
      def emit_normal
        run(Util::DelimitedBody, array)
      end

      # Emit splat argument
      #
      # @return [undefined]
      #
      # @api private
      #
      def emit_splat
        return unless splat?
        emit(', ') if normal?
        visit(splat) 
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
to_source-0.2.20 lib/to_source/emitter/actual_arguments.rb
to_source-0.2.19 lib/to_source/emitter/actual_arguments.rb
to_source-0.2.18 lib/to_source/emitter/actual_arguments.rb
to_source-0.2.17 lib/to_source/emitter/actual_arguments.rb
to_source-0.2.16 lib/to_source/emitter/actual_arguments.rb