" I represent a logged set group attached to a prescribed set group. I own the logged sets and any execution-specific group data such as notes. " Class { #name : 'MFTSetGroupLog', #superclass : 'MFTObject', #instVars : [ 'prescription', 'sets', 'notes' ], #category : 'MyFitnessTracker-Core-Logging', #package : 'MyFitnessTracker-Core', #tag : 'Logging' } { #category : 'accessing' } MFTSetGroupLog class >> forPrescription: aMFTSetGroupPrescription [ ^ self new prescription: aMFTSetGroupPrescription; sets: (aMFTSetGroupPrescription sets collect: [ :each | MFTSetLog forPrescription: each ]) ] { #category : 'initialization' } MFTSetGroupLog >> addSet: aMFTSetLog [ sets addLast: aMFTSetLog ] { #category : 'initialization' } MFTSetGroupLog >> addSet: aMFTSetLog1 before: aMFTsetLog2 [ sets add: aMFTSetLog1 before: aMFTsetLog2 ] { #category : 'initialization' } MFTSetGroupLog >> canonicalName [ ^ prescription ifNil: [ 'prescriptionless set group' ] ifNotNil: [ prescription canonicalName ] ] { #category : 'accessing' } MFTSetGroupLog >> indexOfSet: aMFTSetLog [ ^ sets indexOf: aMFTSetLog ] { #category : 'initialization' } MFTSetGroupLog >> initialize [ super initialize. sets := OrderedCollection new. notes := String new ] { #category : 'as yet unclassified' } MFTSetGroupLog >> intensityFactor [ | weightedIntensity totalVolume | sets ifEmpty: [ ^ 0 ]. totalVolume := self volume. totalVolume = 0 ifTrue: [ ^ 0 ]. weightedIntensity := sets sum: [ :each | each intensityFactor * each volume ]. ^ (weightedIntensity / totalVolume) asFloat round: 1 ] { #category : 'initialization' } MFTSetGroupLog >> isCompletelyLogged [ ^ sets allSatisfy: #isLogged ] { #category : 'initialization' } MFTSetGroupLog >> notes [ ^ notes ] { #category : 'initialization' } MFTSetGroupLog >> notes: aString [ notes := aString ] { #category : 'initialization' } MFTSetGroupLog >> prescription [ ^ prescription ] { #category : 'initialization' } MFTSetGroupLog >> prescription: aMFTSetGroupPrescription [ prescription := aMFTSetGroupPrescription ] { #category : 'removing' } MFTSetGroupLog >> removeSet: aMFTSetLog [ sets remove: aMFTSetLog ] { #category : 'initialization' } MFTSetGroupLog >> setLogForPrescription: aMFTSetPrescription [ ^ sets detect: [ :each | each prescription == aMFTSetPrescription ] ifNone: [ self error: 'Unknown set prescription for this group.' ] ] { #category : 'initialization' } MFTSetGroupLog >> sets [ ^ sets ] { #category : 'initialization' } MFTSetGroupLog >> sets: aMFTSetLogCollection [ sets := aMFTSetLogCollection ] { #category : 'as yet unclassified' } MFTSetGroupLog >> setsGroupedByExercise [ ^ sets groupedBy: #exercise ] { #category : 'testing' } MFTSetGroupLog >> uniqueExercisesInSets [ ^ prescription uniqueExercisesInSets ] { #category : 'initialization' } MFTSetGroupLog >> volume [ ^ sets sum: #volume ]