Class: Gini::Api::DocumentSet

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/gini-api/documentset.rb

Overview

Set of documents resulting from search or list query

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, data) ⇒ DocumentSet

Instantiate a new Gini::Api::Document object from URL

Parameters:

  • api (Gini::Api::Client)

    Gini::Api::Client object

  • data (Hash)

    Container for documents

Options Hash (data):

  • :totalCount (Integer)

    Total number of documents

  • :documents (Aarray)

    List of documents including all data


20
21
22
23
24
25
# File 'lib/gini-api/documentset.rb', line 20

def initialize(api, data)
  @total     = data[:totalCount]
  @documents = data[:documents].map do |doc|
    Gini::Api::Document.new(api, doc[:_links][:document], doc)
  end
end

Instance Attribute Details

#documentsObject (readonly)

Returns the value of attribute documents


8
9
10
# File 'lib/gini-api/documentset.rb', line 8

def documents
  @documents
end

#offsetObject (readonly)

Returns the value of attribute offset


8
9
10
# File 'lib/gini-api/documentset.rb', line 8

def offset
  @offset
end

#totalObject (readonly)

Returns the value of attribute total


8
9
10
# File 'lib/gini-api/documentset.rb', line 8

def total
  @total
end

Instance Method Details

#eachObject

Allow iteration on documents by yielding documents Required by Enumerable mixin


30
31
32
# File 'lib/gini-api/documentset.rb', line 30

def each
  @documents.each { |d| yield(d) }
end