Sha256: 9a742406e7a6a8e94cecb1ad7e7db733d651269a144fd6c7650ef5d96282fdb0

Contents?: true

Size: 997 Bytes

Versions: 1

Compression:

Stored size: 997 Bytes

Contents

# encoding: UTF-8

module Esearch
  class Presenter

    # Presenter for elasticsearch result hits
    class Hits < self
      include Enumerable

      # Enumerate contents
      #
      # @return [self]
      #   if block given
      #
      # @return [Enumerator<Hit>]
      #   otherwise
      #
      # @api private
      #
      def each
        return to_enum unless block_given?

        hits.each do |hit|
          yield Hit.new(hit)
        end

        self
      end

      # Return amount of hits in this request
      #
      # @return [Fixnum]
      #
      # @api private
      #
      def size
        hits.size
      end

      # Return total amount of hits in the query
      #
      # @return [Fixnum]
      #
      # @api private
      #
      expose_primitive('total')

    private

      # Return raw hits
      #
      # @return [Array]
      #
      # @api private
      #
      expose_primitive(:hits)
      private :hits

    end # Hits
  end # Presenter
end # Esearch

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
esearch-0.2.2 lib/esearch/presenter/hits.rb