Update core.

Commit
6e6e25d573169b748785e996d13333210bb1eeac
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
src/MyFitnessTracker-Core/MFTActivity.class.st
index 00000000..987b625f 000000..100644
@@ -0,0 +1,78 @@
1 Added: Class {
2 Added: #name : 'MFTActivity',
3 Added: #superclass : 'MFTObject',
4 Added: #instVars : [
5 Added: 'planned',
6 Added: 'started',
7 Added: 'completed'
8 Added: ],
9 Added: #category : 'MyFitnessTracker-Core',
10 Added: #package : 'MyFitnessTracker-Core'
11 Added: }
12 Added:
13 Added: { #category : 'accessing' }
14 Added: MFTActivity >> completed [
15 Added:
16 Added: ^ completed
17 Added: ]
18 Added:
19 Added: { #category : 'accessing' }
20 Added: MFTActivity >> completed: aDateAndTime [
21 Added:
22 Added: completed := aDateAndTime
23 Added: ]
24 Added:
25 Added: { #category : 'initialization' }
26 Added: MFTActivity >> initialize [
27 Added:
28 Added: super initialize.
29 Added: planned := DateAndTime now
30 Added: ]
31 Added:
32 Added: { #category : 'testing' }
33 Added: MFTActivity >> isCompleted [
34 Added:
35 Added: ^ completed isNotNil
36 Added: ]
37 Added:
38 Added: { #category : 'testing' }
39 Added: MFTActivity >> isLive [
40 Added:
41 Added: ^ self isStarted and: self isCompleted not
42 Added: ]
43 Added:
44 Added: { #category : 'testing' }
45 Added: MFTActivity >> isPlanned [
46 Added:
47 Added: ^ planned isNotNil
48 Added: ]
49 Added:
50 Added: { #category : 'testing' }
51 Added: MFTActivity >> isStarted [
52 Added:
53 Added: ^ started isNotNil
54 Added: ]
55 Added:
56 Added: { #category : 'accessing' }
57 Added: MFTActivity >> planned [
58 Added:
59 Added: ^ planned
60 Added: ]
61 Added:
62 Added: { #category : 'accessing' }
63 Added: MFTActivity >> planned: aDateAndTime [
64 Added:
65 Added: planned := aDateAndTime
66 Added: ]
67 Added:
68 Added: { #category : 'accessing' }
69 Added: MFTActivity >> started [
70 Added:
71 Added: ^ started
72 Added: ]
73 Added:
74 Added: { #category : 'accessing' }
75 Added: MFTActivity >> started: aDateAndTime [
76 Added:
77 Added: started := aDateAndTime
78 Added: ]
src/MyFitnessTracker-Core/MFTRest.class.st
index cc601442..6cfae637 100644..100644
@@ -1,6 +1,6 @@
1 1 Class {
2 2 #name : 'MFTRest',
3 Removed: #superclass : 'MFTObject',
3 Added: #superclass : 'MFTActivity',
4 4 #instVars : [
5 5 'duration'
6 6 ],
src/MyFitnessTracker-Core/MFTRoutine.class.st
index 53e60dcc..cf14171f 100644..100644
@@ -6,16 +6,19 @@
6 6 #superclass : 'MFTObject',
7 7 #instVars : [
8 8 'trainee',
9 Removed: 'cycle'
9 Added: 'title',
10 Added: 'cycle',
11 Added: 'started'
10 12 ],
11 13 #category : 'MyFitnessTracker-Core',
12 14 #package : 'MyFitnessTracker-Core'
13 15 }
14 16
15 Removed: { #category : 'as yet unclassified' }
17 Added: { #category : 'heavy duty' }
16 18 MFTRoutine class >> heavyDutyOneIdealRoutine [
17 19
18 20 ^ self new
21 Added: title: 'Heavy Duty I: Ideal Routine';
19 22 addWorkout: MFTWorkout heavyDutyOneDay1;
20 23 addRest: (MFTRest duration: 4 days);
21 24 addWorkout: MFTWorkout heavyDutyOneDay2;
@@ -25,7 +28,7 @@
25 28 yourself
26 29 ]
27 30
28 Removed: { #category : 'as yet unclassified' }
31 Added: { #category : 'placeholder' }
29 32 MFTRoutine class >> placeholder [
30 33
31 34 ^ self new
@@ -36,6 +39,23 @@
36 39 yourself
37 40 ]
38 41
42 Added: { #category : 'as yet unclassified' }
43 Added: MFTRoutine >> activityOnDate: aDate [
44 Added:
45 Added: | daysElapsed cycleDuration |
46 Added: started ifNil: [ ^ nil ].
47 Added:
48 Added: daysElapsed := (aDate - started) asDays asInteger.
49 Added: cycleDuration := self cycleDuration asDays asInteger.
50 Added: ^ cycle at: daysElapsed % cycleDuration
51 Added: ]
52 Added:
53 Added: { #category : 'as yet unclassified' }
54 Added: MFTRoutine >> activityToday [
55 Added:
56 Added: ^ self activityOnDate: Date today
57 Added: ]
58 Added:
39 59 { #category : 'adding' }
40 60 MFTRoutine >> addRest: aMFTRest [
41 61
@@ -58,7 +78,7 @@
58 78 { #category : 'initialization' }
59 79 MFTRoutine >> canonicalName [
60 80
61 Removed: ^ self workouts size asString , ' workouts'
81 Added: ^ title
62 82 ]
63 83
64 84 { #category : 'as yet unclassified' }
@@ -68,6 +88,12 @@
68 88 ]
69 89
70 90 { #category : 'accessing' }
91 Added: MFTRoutine >> cycle [
92 Added:
93 Added: ^ cycle
94 Added: ]
95 Added:
96 Added: { #category : 'accessing' }
71 97 MFTRoutine >> cycleDuration [
72 98 "I add workout days and rest days."
73 99
@@ -93,13 +119,38 @@
93 119 ^ self workouts select: #isPlanned
94 120 ]
95 121
122 Added: { #category : 'as yet unclassified' }
123 Added: MFTRoutine >> startToday [
124 Added:
125 Added: started := Date today.
126 Added: cycle first started: Date today
127 Added: ]
128 Added:
96 129 { #category : 'accessing' }
97 Removed: MFTRoutine >> routine [
130 Added: MFTRoutine >> started [
98 131
99 Removed: ^ cycle
132 Added: ^ started
100 133 ]
101 134
102 135 { #category : 'accessing' }
136 Added: MFTRoutine >> started: aDate [
137 Added:
138 Added: started := aDate
139 Added: ]
140 Added:
141 Added: { #category : 'accessing' }
142 Added: MFTRoutine >> title [
143 Added:
144 Added: ^ title
145 Added: ]
146 Added:
147 Added: { #category : 'accessing' }
148 Added: MFTRoutine >> title: aString [
149 Added:
150 Added: title := aString
151 Added: ]
152 Added:
153 Added: { #category : 'accessing' }
103 154 MFTRoutine >> totalRestDuration [
104 155
105 156 ^ (cycle
@@ -122,5 +173,5 @@
122 173 { #category : 'as yet unclassified' }
123 174 MFTRoutine >> workouts [
124 175
125 Removed: ^ self routine select: [ :each | each class = MFTWorkout ]
176 Added: ^ self cycle select: [ :each | each class = MFTWorkout ]
126 177 ]
src/MyFitnessTracker-Core/MFTWorkout.class.st
index e83a806d..a616d272 100644..100644
@@ -3,13 +3,10 @@
3 3 "
4 4 Class {
5 5 #name : 'MFTWorkout',
6 Removed: #superclass : 'MFTObject',
6 Added: #superclass : 'MFTActivity',
7 7 #instVars : [
8 8 'trainee',
9 9 'setGroups',
10 Removed: 'planned',
11 Removed: 'started',
12 Removed: 'completed',
13 10 'routine'
14 11 ],
15 12 #category : 'MyFitnessTracker-Core',
@@ -170,68 +167,17 @@
170 167 { #category : 'initialization' }
171 168 MFTWorkout >> canonicalName [
172 169
173 Removed: ^ self isCompleted
174 Removed: ifTrue: [ 'completed ' , completed asString ]
175 Removed: ifFalse: [ 'planned ' , planned asString ]
170 Added: ^ self status
176 171 ]
177 172
178 Removed: { #category : 'accessing' }
179 Removed: MFTWorkout >> completed [
180 Removed:
181 Removed: ^ completed
182 Removed: ]
183 Removed:
184 Removed: { #category : 'accessing' }
185 Removed: MFTWorkout >> completed: aDateAndTime [
186 Removed:
187 Removed: completed := aDateAndTime
188 Removed: ]
189 Removed:
190 173 { #category : 'initialization' }
191 174 MFTWorkout >> initialize [
192 175
193 176 super initialize.
194 Removed: planned := DateAndTime today.
195 177 setGroups := OrderedCollection new
196 178 ]
197 179
198 Removed: { #category : 'testing' }
199 Removed: MFTWorkout >> isCompleted [
200 Removed:
201 Removed: ^ completed isNotNil
202 Removed: ]
203 Removed:
204 Removed: { #category : 'testing' }
205 Removed: MFTWorkout >> isLive [
206 Removed:
207 Removed: ^ self isStarted and: self isCompleted not
208 Removed: ]
209 Removed:
210 Removed: { #category : 'testing' }
211 Removed: MFTWorkout >> isPlanned [
212 Removed:
213 Removed: ^ planned isNotNil
214 Removed: ]
215 Removed:
216 Removed: { #category : 'testing' }
217 Removed: MFTWorkout >> isStarted [
218 Removed:
219 Removed: ^ started isNotNil
220 Removed: ]
221 Removed:
222 180 { #category : 'accessing' }
223 Removed: MFTWorkout >> planned [
224 Removed:
225 Removed: ^ planned
226 Removed: ]
227 Removed:
228 Removed: { #category : 'accessing' }
229 Removed: MFTWorkout >> planned: aDateAndTime [
230 Removed:
231 Removed: planned := aDateAndTime
232 Removed: ]
233 Removed:
234 Removed: { #category : 'accessing' }
235 181 MFTWorkout >> routine [
236 182
237 183 ^ routine
@@ -273,24 +219,12 @@
273 219 ]
274 220
275 221 { #category : 'accessing' }
276 Removed: MFTWorkout >> started [
277 Removed:
278 Removed: ^ started
279 Removed: ]
280 Removed:
281 Removed: { #category : 'accessing' }
282 Removed: MFTWorkout >> started: aDateAndTime [
283 Removed:
284 Removed: started := aDateAndTime
285 Removed: ]
286 Removed:
287 Removed: { #category : 'accessing' }
288 222 MFTWorkout >> status [
289 223
290 224 self isCompleted ifTrue: [
291 Removed: ^ 'completed ' , completed asDate asString ].
292 Removed: self isLive ifTrue: [ ^ 'started ' , started asDate asString ].
293 Removed: self isPlanned ifTrue: [ ^ 'planned ' , planned asDate asString ].
225 Added: ^ 'completed ' , self completed asDate asString ].
226 Added: self isLive ifTrue: [ ^ 'started ' , self started asDate asString ].
227 Added: self isPlanned ifTrue: [ ^ 'planned ' , self planned asDate asString ].
294 228 ^ 'no status'
295 229 ]
296 230