Class: DataCatalog::Cursor
Instance Attribute Summary collapse
-
#document_count ⇒ Object
readonly
Returns the value of attribute document_count.
-
#page_count ⇒ Object
readonly
Returns the value of attribute page_count.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
Instance Method Summary collapse
- #[](i) ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
- #first ⇒ Object
-
#initialize(options) ⇒ Cursor
constructor
A new instance of Cursor.
- #last ⇒ Object
- #length ⇒ Object
- #page(page_number) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(options) ⇒ Cursor
Returns a new instance of Cursor.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cursor.rb', line 11 def initialize() @klass = [:klass] @query_hash = [:query_hash] @response = [:response] @uri = [:uri] @page_size = @response['page_size'] @document_count = @response['document_count'] @members = members(@response) @page_count = @response['page_count'] end |
Instance Attribute Details
#document_count ⇒ Object (readonly)
Returns the value of attribute document_count.
5 6 7 |
# File 'lib/cursor.rb', line 5 def document_count @document_count end |
#page_count ⇒ Object (readonly)
Returns the value of attribute page_count.
6 7 8 |
# File 'lib/cursor.rb', line 6 def page_count @page_count end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
7 8 9 |
# File 'lib/cursor.rb', line 7 def page_size @page_size end |
Instance Method Details
#[](i) ⇒ Object
23 24 25 |
# File 'lib/cursor.rb', line 23 def [](i) member_at(i) end |
#each ⇒ Object
27 28 29 |
# File 'lib/cursor.rb', line 27 def each @document_count.times { |i| yield member_at(i) } end |
#empty? ⇒ Boolean
31 32 33 |
# File 'lib/cursor.rb', line 31 def empty? @document_count == 0 end |
#first ⇒ Object
35 36 37 |
# File 'lib/cursor.rb', line 35 def first member_at(0) end |
#last ⇒ Object
39 40 41 |
# File 'lib/cursor.rb', line 39 def last member_at(@document_count - 1) end |
#length ⇒ Object
43 44 45 |
# File 'lib/cursor.rb', line 43 def length @document_count end |
#page(page_number) ⇒ Object
47 48 49 |
# File 'lib/cursor.rb', line 47 def page(page_number) page_indices(page_number).map { |i| member_at(i) } end |
#size ⇒ Object
51 52 53 |
# File 'lib/cursor.rb', line 51 def size @members.size end |