Class: Company::Selection
- Inherits:
-
Collection
- Object
- Collection
- Company::Selection
- Defined in:
- lib/company/selection.rb
Overview
A list narrowed by something the platform could not be asked to narrow by: the list it came from is walked as it was, and only what the rule keeps comes through.
Instance Method Summary collapse
-
#between(from, to) ⇒ Selection
The same rule, over the list narrowed to the window.
- #each {|Resource| ... } ⇒ Object
-
#initialize(collection:) {|Resource| ... } ⇒ Selection
constructor
A new instance of Selection.
Methods inherited from Collection
#ids, #includes, #of, #past, #upcoming
Constructor Details
#initialize(collection:) {|Resource| ... } ⇒ Selection
Returns a new instance of Selection.
7 8 9 10 |
# File 'lib/company/selection.rb', line 7 def initialize(collection:, &kept) @collection = collection @kept = kept end |
Instance Method Details
#between(from, to) ⇒ Selection
Returns the same rule, over the list narrowed to the window.
20 |
# File 'lib/company/selection.rb', line 20 def between(from, to) = self.class.new(collection: @collection.between(from, to), &@kept) |
#each {|Resource| ... } ⇒ Object
13 14 15 |
# File 'lib/company/selection.rb', line 13 def each @collection.each { |record| yield record if @kept.call record } end |