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



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

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

#each(&block) ⇒ Object



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

#each_page(&block) ⇒ Object



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

#empty?Boolean



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

#firstObject



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

def first
  first_page
  @objects.first
end

#lastObject



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

def last
  last_page
  @objects.last
end