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

- (PageOfResults) initialize(api, json, &block)



71
72
73
74
# File 'lib/sequencescape-api/finder_methods.rb', line 71

def initialize(api, json, &block)
  @api, @ctor = api, block
  update_from_json(json)
end

Instance Attribute Details

- (Object) size (readonly)

Returns the value of attribute size



69
70
71
# File 'lib/sequencescape-api/finder_methods.rb', line 69

def size
  @size
end

Instance Method Details

- (Object) each(&block)



83
84
85
86
87
# File 'lib/sequencescape-api/finder_methods.rb', line 83

def each(&block)
  walk_pages do
    @objects.each(&block)
  end
end

- (Object) each_page(&block)



89
90
91
92
93
# File 'lib/sequencescape-api/finder_methods.rb', line 89

def each_page(&block)
  walk_pages do
    yield(@objects.dup)
  end
end

- (Boolean) empty?



76
77
78
79
80
81
# File 'lib/sequencescape-api/finder_methods.rb', line 76

def empty?
  return @size.zero? if api.capabilities.size_in_pages?

  first_page
  @objects.empty?
end

- (Object) first



95
96
97
98
# File 'lib/sequencescape-api/finder_methods.rb', line 95

def first
  first_page
  @objects.first
end

- (Object) last



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

def last
  last_page
  @objects.last
end