Class: Sequencescape::Api::PageOfResults

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

Defined Under Namespace

Classes: UpdateHandler

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#sizeObject (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_pageObject



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

Returns:

  • (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

#firstObject



117
118
119
120
# File 'lib/sequencescape-api/finder_methods.rb', line 117

def first
  first_page
  @objects.first
end

#lastObject



122
123
124
125
# File 'lib/sequencescape-api/finder_methods.rb', line 122

def last
  last_page
  @objects.last
end

#present?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/sequencescape-api/finder_methods.rb', line 101

def present?
  !empty?
end