Class: Company::Collection
- Inherits:
-
Object
- Object
- Company::Collection
- Includes:
- Enumerable
- Defined in:
- lib/company/collection.rb
Overview
A list of records an account holds, walked however the platform pages it and narrowed to a
window measured from now, or to one technician. A gem answers each, and between with
the same list narrowed to what starts between two moments, either one open.
Instance Method Summary collapse
-
#ids ⇒ Array<String>
ID of every record, the list walked; a platform with a cheaper way to ask answers it that way instead.
-
#includes(*names) ⇒ Collection
What to bring back beside each record, for a platform that charges for the asking.
-
#of(id) ⇒ Collection
A platform that can ask its server for one technician's work narrows the list there; one that cannot walks the list and keeps what they turn out to be on.
-
#past(within = nil) ⇒ Collection
The same list, narrowed to what started before now.
-
#upcoming(within = nil) ⇒ Collection
Both ends are measured from one moment, so nothing slides between them.
Instance Method Details
#ids ⇒ Array<String>
Returns ID of every record, the list walked; a platform with a cheaper way to ask answers it that way instead.
45 |
# File 'lib/company/collection.rb', line 45 def ids = map(&:id) |
#includes(*names) ⇒ Collection
What to bring back beside each record, for a platform that charges for the asking. One that answers a record whole has nothing to ask for and answers the same list, so a caller names what it reads without knowing which kind of platform it is talking to.
28 |
# File 'lib/company/collection.rb', line 28 def includes(*names) = self |
#of(id) ⇒ Collection
A platform that can ask its server for one technician's work narrows the list there; one that cannot walks the list and keeps what they turn out to be on. It takes the ID the platform files them under rather than the technician, that being the whole of what any platform asks by: a caller holding a record of its own then names the ID it knows, rather than dressing it up as a technician it does not have.
37 38 39 40 41 |
# File 'lib/company/collection.rb', line 37 def of(id) Selection.new(collection: self) do |record| record.technicians.any? { |technician| technician.id == id } end end |
#past(within = nil) ⇒ Collection
Returns the same list, narrowed to what started before now.
18 19 20 21 |
# File 'lib/company/collection.rb', line 18 def past(within = nil) now = Time.now between within && now - within, now end |
#upcoming(within = nil) ⇒ Collection
Both ends are measured from one moment, so nothing slides between them.
11 12 13 14 |
# File 'lib/company/collection.rb', line 11 def upcoming(within = nil) now = Time.now between now, within && now + within end |