Class: Solr::CursorStream::Response

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/solr/cursorstream/response.rb

Overview

Wrapper around a Faraday::Response that provides sugar methods to get solr docs, numFound, and the cursor value

Instance Method Summary collapse

Constructor Details

#initialize(faraday_response) ⇒ Response

Returns a new instance of Response.

Parameters:

  • faraday_response (Faraday::Response)


9
10
11
12
13
14
# File 'lib/solr/cursorstream/response.rb', line 9

def initialize(faraday_response)
  super
  @base_resp = faraday_response
  @resp = faraday_response.body
  __setobj__(@resp)
end

Instance Method Details

#cursorString

Returns value of the cursor as returned from solr.

Returns:

  • (String)

    value of the cursor as returned from solr



27
28
29
# File 'lib/solr/cursorstream/response.rb', line 27

def cursor
  @resp["nextCursorMark"]
end

#docsArray<Hash>

Returns Array of solr documents returned, as simple hashes.

Returns:

  • (Array<Hash>)

    Array of solr documents returned, as simple hashes



17
18
19
# File 'lib/solr/cursorstream/response.rb', line 17

def docs
  @resp["response"]["docs"]
end

#num_foundInteger

Returns Number of documents found for the solr query.

Returns:

  • (Integer)

    Number of documents found for the solr query



22
23
24
# File 'lib/solr/cursorstream/response.rb', line 22

def num_found
  @resp["response"]["numFound"]
end