[Pharo] Personal fitness tracker web app.
1
"
2
I represent a group of sets prescribed for a workout.
3
"
4
Class {
5
#name : 'MFTSetGroupPrescription',
6
#superclass : 'MFTObject',
7
#instVars : [
8
'sets'
9
],
10
#category : 'MyFitnessTracker-Core-Prescription',
11
#package : 'MyFitnessTracker-Core',
12
#tag : 'Prescription'
13
}
14
15
{ #category : 'as yet unclassified' }
16
MFTSetGroupPrescription class >> withSets: aMFTSetPrescriptionCollection [
17
18
^ self new
19
sets: aMFTSetPrescriptionCollection asOrderedCollection;
20
validate;
21
yourself
22
]
23
24
{ #category : 'accessing' }
25
MFTSetGroupPrescription >> alternativeExercisesFor: aMFTExercise [
26
27
^ sets
28
detect: [ :each | each exercise = aMFTExercise ]
29
ifFound: [ :set | set alternativeExercises ]
30
ifNone: [ nil ]
31
]
32
33
{ #category : 'initialization' }
34
MFTSetGroupPrescription >> initialize [
35
36
super initialize.
37
sets := OrderedCollection new
38
]
39
40
{ #category : 'testing' }
41
MFTSetGroupPrescription >> setCount [
42
43
^ sets size
44
]
45
46
{ #category : 'accessing' }
47
MFTSetGroupPrescription >> sets [
48
49
^ sets
50
]
51
52
{ #category : 'accessing' }
53
MFTSetGroupPrescription >> sets: aMFTSetPrescriptionCollection [
54
55
sets := aMFTSetPrescriptionCollection
56
]
57
58
{ #category : 'testing' }
59
MFTSetGroupPrescription >> uniqueExercisesInSets [
60
"I answer unique exercises across all sets."
61
62
^ (sets collect: #exercise) asSet
63
]
64
65
{ #category : 'validation' }
66
MFTSetGroupPrescription >> validate [
67
68
self subclassResponsibility
69
]
70