Class: Sequencescape::Api::PageOfResults
- Inherits:
-
Object
- Object
- Sequencescape::Api::PageOfResults
- Includes:
- Enumerable
- Defined in:
- lib/sequencescape-api/finder_methods.rb
Defined Under Namespace
Classes: UpdateHandler
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #each_page ⇒ Object
- #empty? ⇒ Boolean
- #first ⇒ Object
-
#initialize(api, json, &block) ⇒ PageOfResults
constructor
A new instance of PageOfResults.
- #last ⇒ Object
- #present? ⇒ Boolean
Constructor Details
#initialize(api, json, &block) ⇒ PageOfResults
Returns a new instance of PageOfResults.
88 89 90 91 92 |
# File 'lib/sequencescape-api/finder_methods.rb', line 88 def initialize(api, json, &block) @api = api @ctor = block update_from_json(json) end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
85 86 87 |
# File 'lib/sequencescape-api/finder_methods.rb', line 85 def size @size end |
Instance Method Details
#each(&block) ⇒ Object
105 106 107 108 109 |
# File 'lib/sequencescape-api/finder_methods.rb', line 105 def each(&block) walk_pages do @objects.each(&block) end end |
#each_page ⇒ Object
111 112 113 114 115 |
# File 'lib/sequencescape-api/finder_methods.rb', line 111 def each_page walk_pages do yield(@objects.dup) end end |
#empty? ⇒ Boolean
94 95 96 97 98 99 |
# File 'lib/sequencescape-api/finder_methods.rb', line 94 def empty? return @size.zero? if api.capabilities.size_in_pages? first_page @objects.empty? end |
#first ⇒ Object
117 118 119 120 |
# File 'lib/sequencescape-api/finder_methods.rb', line 117 def first first_page @objects.first end |
#last ⇒ Object
122 123 124 125 |
# File 'lib/sequencescape-api/finder_methods.rb', line 122 def last last_page @objects.last end |
#present? ⇒ Boolean
101 102 103 |
# File 'lib/sequencescape-api/finder_methods.rb', line 101 def present? !empty? end |