Class: Async::Slack::Pagination

Inherits:
Representation show all
Includes:
Enumerable
Defined in:
lib/async/slack/search.rb

Direct Known Subclasses

Messages

Instance Method Summary collapse

Instance Method Details

#each(page: 1, count: 100, **parameters) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/async/slack/search.rb', line 30

def each(page: 1, count: 100, **parameters)
	return to_enum(:each, page: page, count: count, **parameters) unless block_given?
	
	collection = self.collection(**parameters)
	
	while true
		representation = collection.get(self.class, page: page, count: count)
		
		records = representation.records
		
		records.each do |value|
			yield represent(representation., value)
		end
		
		# Was this the last page?
		break if records.size < count
		
		page += 1
	end
end

#empty?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/async/slack/search.rb', line 51

def empty?
	self.value.empty?
end