MFTSet can now be represented as, and created from, JSON strings.

Commit
3e13353341f7d9fc26f96da92be01b42a715ad0d
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <marius.peter@tutanota.com>
Committer date
src/MyFitnessTracker/MFTSet.class.st
index 7d1567d2..f046c372 100644..100644
@@ -17,6 +17,18 @@
17 17 #category : #'MyFitnessTracker-Model'
18 18 }
19 19
20 Added: { #category : #'instance creation' }
21 Added: MFTSet class >> fromJson: aJsonString [
22 Added:
23 Added: | dict |
24 Added: dict := WAJsonParser parse: aJsonString.
25 Added: ^ self new
26 Added: reps: (dict at: #reps ifAbsent: MFTUser defaultReps);
27 Added: weight: (dict at: #weight ifAbsent: 0);
28 Added: rpe: (dict at: #rpe ifAbsent: MFTUser defaultRpe);
29 Added: yourself
30 Added: ]
31 Added:
20 32 { #category : #accessing }
21 33 MFTSet class >> reps: anInteger [
22 34
@@ -35,6 +47,15 @@
35 47 ]
36 48
37 49 { #category : #'as yet unclassified' }
50 Added: MFTSet class >> reps: anInteger weight: anInteger2 [
51 Added:
52 Added: ^ self new
53 Added: reps: anInteger;
54 Added: weight: anInteger2;
55 Added: yourself
56 Added: ]
57 Added:
58 Added: { #category : #'as yet unclassified' }
38 59 MFTSet class >> reps: anInteger weight: anInteger2 rpe: anInteger3 [
39 60
40 61 ^ self new
@@ -48,19 +69,17 @@
48 69 MFTSet >> initialize [
49 70
50 71 super initialize.
51 Removed: reps := MFTUser defaultReps.
52 Removed: weight := 0.
53 Removed: rpe := MFTUser defaultRpe
72 Added: reps := MFTUser defaultReps
54 73 ]
55 74
56 75 { #category : #'as yet unclassified' }
57 76 MFTSet >> jsonOn: aRenderer [
58 77
59 78 | dict |
60 Removed: dict := {
61 Removed: (#reps -> reps).
62 Removed: (#weight -> weight).
63 Removed: (#rpe -> rpe) } asDictionary.
79 Added: dict := Dictionary newFrom: {
80 Added: (#reps -> reps).
81 Added: (#weight -> weight).
82 Added: (#rpe -> rpe) }.
64 83 dict jsonOn: aRenderer
65 84 ]
66 85