Class: Esearch::Presenter::Hits

Inherits:
Esearch::Presenter show all
Includes:
Enumerable
Defined in:
lib/esearch/presenter/hits.rb

Overview

Presenter for elasticsearch result hits

Instance Method Summary collapse

Instance Method Details

#each(&block) ⇒ self, Enumerator<Hit>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Enumerate contents

Returns:

  • (self)

    if block given

  • (Enumerator<Hit>)

    otherwise



18
19
20
21
22
23
24
25
26
# File 'lib/esearch/presenter/hits.rb', line 18

def each(&block)
  return to_enum unless block_given?

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

#sizeFixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return amount of hits in this request

Returns:

  • (Fixnum)


34
35
36
# File 'lib/esearch/presenter/hits.rb', line 34

def size
  hits.size
end

#totalFixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return total amount of hits in the query

Returns:

  • (Fixnum)


44
# File 'lib/esearch/presenter/hits.rb', line 44

expose_primitive('total')