fifadat-convert 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,465 @@
1
+ =begin
2
+ "Substitutions":
3
+ [{"IdEvent": null,
4
+ "Period": 5,
5
+ "Reason": 2,
6
+ "SubstitutePosition": 2,
7
+ "IdPlayerOff": "448148",
8
+ "IdPlayerOn": "395318",
9
+ "PlayerOffName":
10
+ [{"Locale": "en-GB", "Description": "Jeremie FRIMPONG"}],
11
+ "PlayerOnName": [{"Locale": "en-GB", "Description": "Wataru ENDO"}],
12
+ "Minute": "60'",
13
+ "IdTeam": "1896634"},
14
+
15
+ "Period"=>??,
16
+ "SubstitutePosition"=>2,
17
+ "IdPlayerOff"=>"403319",
18
+ "IdPlayerOn"=>"436537",
19
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"NASSER ALDAWSARI"}],
20
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"MUSAB ALJUWAYR"}],
21
+ "Minute"=>"", ## note - empty string!!
22
+ "IdTeam"=>"1943992"}
23
+ ---
24
+ "Period"=>17,
25
+ "SubstitutePosition"=>2,
26
+ "IdPlayerOff"=>"473062",
27
+ "IdPlayerOn"=>"418961",
28
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Emiliano MARTINEZ"}],
29
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Anibal MORENO"}],
30
+ "Minute"=>"", ## note - empty string!!
31
+ "IdTeam"=>"1884426"}
32
+ =end
33
+
34
+
35
+
36
+ def _build_sub_minute( h )
37
+
38
+ ## split into minute
39
+ ## and offset (stoppage/injury/added time)
40
+ ## e.g. 90'+11'
41
+
42
+ minute_str = h['Minute']
43
+
44
+ ##
45
+ ## check what is "Period"=>4
46
+ ## minute is "" empty!!
47
+
48
+ if minute_str.nil? || minute_str.empty?
49
+ if h['Period'] == 4 ## quick fix - use 46' half-time sub??
50
+ minute_str = "46'"
51
+ elsif h['Period'] == 8 ## quick fix - use 116' 1st half-time extra time?
52
+ minute_str = "116'"
53
+ elsif h['Period'] == 17 ## quick fix- what is period 17 beyond pens??
54
+ minute_str = "121'"
55
+ else
56
+ puts "!! minute in sub is nil or empty:"
57
+ pp h
58
+ exit 1
59
+ end
60
+ end
61
+
62
+ ## _fmt_minute( *_parse_minute( minute_str ))
63
+
64
+ minute, offset = _parse_minute( minute_str )
65
+
66
+ Minute.new( m: minute,
67
+ offset: offset,
68
+ period: h['Period'] )
69
+ end
70
+
71
+
72
+
73
+ def build_sub( h, players: )
74
+
75
+ minute = _build_sub_minute( h )
76
+
77
+ playerOff = players.find( h['IdPlayerOff'] )
78
+ playerOn = players.find( h['IdPlayerOn'] )
79
+
80
+ ## use N.N. for nil - why? why not?
81
+ playerOn = { name: 'N.N.'} if playerOn.nil?
82
+
83
+ assert( playerOff && playerOn,
84
+ "playerOff and/or playerOn is NIL in #{h.pretty_inspect}")
85
+
86
+ rec = { off: playerOff[ :name ],
87
+ on: playerOn[ :name ],
88
+ minute: minute
89
+ }
90
+
91
+ rec
92
+ end
93
+
94
+
95
+
96
+ def build_subs( recs, players: )
97
+ recs = recs.map { |h| build_sub( h, players: players ) }
98
+ recs
99
+ end
100
+
101
+
102
+ __END__
103
+
104
+
105
+ !! ASSERT FAILED - playerOff and/or playerOn is NIL in {"IdEvent"=>nil,
106
+ "Period"=>5,
107
+ "Reason"=>0,
108
+ "SubstitutePosition"=>3,
109
+ "IdPlayerOff"=>"56496",
110
+ "IdPlayerOn"=>nil,
111
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Anatoli PUZACH"}],
112
+ "PlayerOnName"=>[],
113
+ "Minute"=>"46'",
114
+ "IdTeam"=>"44026"}
115
+
116
+
117
+
118
+
119
+ ! minute in sub is nil or empty:
120
+ {"IdEvent"=>nil,
121
+ "Period"=>4,
122
+ "Reason"=>0,
123
+ "SubstitutePosition"=>3,
124
+ "IdPlayerOff"=>"418747",
125
+ "IdPlayerOn"=>"411174",
126
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Tomas RODRIGUEZ"}],
127
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Jose FAJARDO"}],
128
+ "Minute"=>"",
129
+ "IdTeam"=>"43914"}
130
+
131
+ !! minute in sub is nil or empty:
132
+ {"IdEvent"=>nil,
133
+ "Period"=>4,
134
+ "Reason"=>0,
135
+ "SubstitutePosition"=>1,
136
+ "IdPlayerOff"=>"494351",
137
+ "IdPlayerOn"=>"511022",
138
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Jonas ADJETEY"}],
139
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Kojo Peprah OPPONG"}],
140
+ "Minute"=>"",
141
+ "IdTeam"=>"43860"}
142
+
143
+ !! minute in sub is nil or empty:
144
+ {"IdEvent"=>nil,
145
+ "Period"=>4,
146
+ "Reason"=>0,
147
+ "SubstitutePosition"=>2,
148
+ "IdPlayerOff"=>"441341",
149
+ "IdPlayerOn"=>"441342",
150
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Elisha OWUSU"}],
151
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Abdul FATAWU"}],
152
+ "Minute"=>"",
153
+ "IdTeam"=>"43860"}
154
+
155
+ !! minute in sub is nil or empty:
156
+ {"IdEvent"=>nil,
157
+ "Period"=>4,
158
+ "Reason"=>0,
159
+ "SubstitutePosition"=>2,
160
+ "IdPlayerOff"=>"395216",
161
+ "IdPlayerOn"=>"484141",
162
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"RUBEN NEVES"}],
163
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"JOAO NEVES"}],
164
+ "Minute"=>"",
165
+ "IdTeam"=>"43963"}
166
+
167
+ !! minute in sub is nil or empty:
168
+ {"IdEvent"=>nil,
169
+ "Period"=>4,
170
+ "Reason"=>0,
171
+ "SubstitutePosition"=>1,
172
+ "IdPlayerOff"=>"368649",
173
+ "IdPlayerOn"=>"403002",
174
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"JOAO CANCELO"}],
175
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"DIOGO DALOT"}],
176
+ "Minute"=>"",
177
+ "IdTeam"=>"43963"}
178
+
179
+ !! minute in sub is nil or empty:
180
+ {"IdEvent"=>nil,
181
+ "Period"=>4,
182
+ "Reason"=>0,
183
+ "SubstitutePosition"=>3,
184
+ "IdPlayerOff"=>"299200",
185
+ "IdPlayerOn"=>"401131",
186
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Marko ARNAUTOVIC"}],
187
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Michael Gregoritsch"}],
188
+ "Minute"=>"",
189
+ "IdTeam"=>"43934"}
190
+
191
+ !! minute in sub is nil or empty:
192
+ {"IdEvent"=>nil,
193
+ "Period"=>4,
194
+ "Reason"=>0,
195
+ "SubstitutePosition"=>2,
196
+ "IdPlayerOff"=>"463283",
197
+ "IdPlayerOn"=>"520036",
198
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Romano SCHMID"}],
199
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Paul WANNER"}],
200
+ "Minute"=>"",
201
+ "IdTeam"=>"43934"}
202
+
203
+ !! minute in sub is nil or empty:
204
+ {"IdEvent"=>nil,
205
+ "Period"=>4,
206
+ "Reason"=>0,
207
+ "SubstitutePosition"=>2,
208
+ "IdPlayerOff"=>"385531",
209
+ "IdPlayerOn"=>"385248",
210
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Xaver Schlager"}],
211
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Florian GRILLITSCH"}],
212
+ "Minute"=>"",
213
+ "IdTeam"=>"43934"}
214
+
215
+ !! minute in sub is nil or empty:
216
+ {"IdEvent"=>nil,
217
+ "Period"=>4,
218
+ "Reason"=>0,
219
+ "SubstitutePosition"=>3,
220
+ "IdPlayerOff"=>"511875",
221
+ "IdPlayerOn"=>"396950",
222
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"ODEH FAKHOURY"}],
223
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"MAHMOUD ALMARDI"}],
224
+ "Minute"=>"",
225
+ "IdTeam"=>"43820"}
226
+
227
+ !! minute in sub is nil or empty:
228
+ {"IdEvent"=>nil,
229
+ "Period"=>4,
230
+ "Reason"=>0,
231
+ "SubstitutePosition"=>3,
232
+ "IdPlayerOff"=>"498514",
233
+ "IdPlayerOn"=>"431211",
234
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"ALI AZAIZEH"}],
235
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"MOUSA ALTAMARI"}],
236
+ "Minute"=>"",
237
+ "IdTeam"=>"43820"}
238
+
239
+ !! minute in sub is nil or empty:
240
+ {"IdEvent"=>nil,
241
+ "Period"=>4,
242
+ "Reason"=>0,
243
+ "SubstitutePosition"=>3,
244
+ "IdPlayerOff"=>"486161",
245
+ "IdPlayerOn"=>"494248",
246
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Relebohile MOFOKENG"}],
247
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Thalente MBATHA"}],
248
+ "Minute"=>"",
249
+ "IdTeam"=>"43883"}
250
+
251
+ !! minute in sub is nil or empty:
252
+ {"IdEvent"=>nil,
253
+ "Period"=>4,
254
+ "Reason"=>0,
255
+ "SubstitutePosition"=>2,
256
+ "IdPlayerOff"=>"411726",
257
+ "IdPlayerOn"=>"463746",
258
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"LUCAS PAQUETA"}],
259
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"ENDRICK"}],
260
+ "Minute"=>"",
261
+ "IdTeam"=>"43924"}
262
+
263
+ !! minute in sub is nil or empty:
264
+ {"IdEvent"=>nil,
265
+ "Period"=>4,
266
+ "Reason"=>0,
267
+ "SubstitutePosition"=>2,
268
+ "IdPlayerOff"=>"492363",
269
+ "IdPlayerOn"=>"379953",
270
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Felix NMECHA"}],
271
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Leon GORETZKA"}],
272
+ "Minute"=>"",
273
+ "IdTeam"=>"43948"}
274
+
275
+ !! minute in sub is nil or empty:
276
+ {"IdEvent"=>nil,
277
+ "Period"=>17,
278
+ "Reason"=>0,
279
+ "SubstitutePosition"=>2,
280
+ "IdPlayerOff"=>"369761",
281
+ "IdPlayerOn"=>"486875",
282
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Miguel ALMIRON"}],
283
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Gustavo VELAZQUEZ"}],
284
+ "Minute"=>"",
285
+ "IdTeam"=>"43928"}
286
+
287
+ !! minute in sub is nil or empty:
288
+ {"IdEvent"=>nil,
289
+ "Period"=>4,
290
+ "Reason"=>0,
291
+ "SubstitutePosition"=>2,
292
+ "IdPlayerOff"=>"389784",
293
+ "IdPlayerOn"=>"463489",
294
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Alan FRANCO"}],
295
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Yaimar MEDINA"}],
296
+ "Minute"=>"",
297
+ "IdTeam"=>"43927"}
298
+
299
+ !! minute in sub is nil or empty:
300
+ {"IdEvent"=>nil,
301
+ "Period"=>4,
302
+ "Reason"=>0,
303
+ "SubstitutePosition"=>1,
304
+ "IdPlayerOff"=>"463465",
305
+ "IdPlayerOn"=>"402974",
306
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Joel ORDONEZ"}],
307
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Angelo PRECIADO"}],
308
+ "Minute"=>"",
309
+ "IdTeam"=>"43927"}
310
+
311
+ !! minute in sub is nil or empty:
312
+ {"IdEvent"=>nil,
313
+ "Period"=>4,
314
+ "Reason"=>0,
315
+ "SubstitutePosition"=>3,
316
+ "IdPlayerOff"=>"448362",
317
+ "IdPlayerOn"=>"358112",
318
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Charles DE KETELAERE"}],
319
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Romelu LUKAKU"}],
320
+ "Minute"=>"",
321
+ "IdTeam"=>"43935"}
322
+
323
+ !! minute in sub is nil or empty:
324
+ {"IdEvent"=>nil,
325
+ "Period"=>4,
326
+ "Reason"=>0,
327
+ "SubstitutePosition"=>2,
328
+ "IdPlayerOff"=>"385531",
329
+ "IdPlayerOn"=>"385248",
330
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Xaver Schlager"}],
331
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Florian GRILLITSCH"}],
332
+ "Minute"=>"",
333
+ "IdTeam"=>"43934"}
334
+
335
+ !! minute in sub is nil or empty:
336
+ {"IdEvent"=>nil,
337
+ "Period"=>4,
338
+ "Reason"=>0,
339
+ "SubstitutePosition"=>2,
340
+ "IdPlayerOff"=>"441088",
341
+ "IdPlayerOn"=>"463800",
342
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Nicolas SEIWALD"}],
343
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Carney CHUKWUEMEKA"}],
344
+ "Minute"=>"",
345
+ "IdTeam"=>"43934"}
346
+
347
+ !! minute in sub is nil or empty:
348
+ {"IdEvent"=>nil,
349
+ "Period"=>4,
350
+ "Reason"=>0,
351
+ "SubstitutePosition"=>3,
352
+ "IdPlayerOff"=>"430070",
353
+ "IdPlayerOn"=>"485068",
354
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Ante BUDIMIR"}],
355
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Igor MATANOVIC"}],
356
+ "Minute"=>"",
357
+ "IdTeam"=>"43938"}
358
+
359
+ !! minute in sub is nil or empty:
360
+ {"IdEvent"=>nil,
361
+ "Period"=>4,
362
+ "Reason"=>0,
363
+ "SubstitutePosition"=>1,
364
+ "IdPlayerOff"=>"423522",
365
+ "IdPlayerOn"=>"494411",
366
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Jordan BOS"}],
367
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Kai TREWIN"}],
368
+ "Minute"=>"",
369
+ "IdTeam"=>"43976"}
370
+
371
+ !! minute in sub is nil or empty:
372
+ {"IdEvent"=>nil,
373
+ "Period"=>17,
374
+ "Reason"=>0,
375
+ "SubstitutePosition"=>2,
376
+ "IdPlayerOff"=>"430452",
377
+ "IdPlayerOn"=>"406606",
378
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Connor METCALFE"}],
379
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Awer MABIL"}],
380
+ "Minute"=>"",
381
+ "IdTeam"=>"43976"}
382
+
383
+ !! minute in sub is nil or empty:
384
+ {"IdEvent"=>nil,
385
+ "Period"=>17,
386
+ "Reason"=>0,
387
+ "SubstitutePosition"=>2,
388
+ "IdPlayerOff"=>"430440",
389
+ "IdPlayerOn"=>"498421",
390
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Aiden ONEILL"}],
391
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Paul OKON-ENGSTLER"}],
392
+ "Minute"=>"",
393
+ "IdTeam"=>"43976"}
394
+
395
+ !! minute in sub is nil or empty:
396
+ {"IdEvent"=>nil,
397
+ "Period"=>8,
398
+ "Reason"=>0,
399
+ "SubstitutePosition"=>3,
400
+ "IdPlayerOff"=>"430476",
401
+ "IdPlayerOn"=>"495488",
402
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"OMAR MARMOUSH"}],
403
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"HAMZA ABDELKARIM"}],
404
+ "Minute"=>"",
405
+ "IdTeam"=>"43855"}
406
+
407
+ !! minute in sub is nil or empty:
408
+ {"IdEvent"=>nil,
409
+ "Period"=>4,
410
+ "Reason"=>0,
411
+ "SubstitutePosition"=>2,
412
+ "IdPlayerOff"=>"269058",
413
+ "IdPlayerOn"=>"473050",
414
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"James RODRIGUEZ"}],
415
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Richard RIOS"}],
416
+ "Minute"=>"",
417
+ "IdTeam"=>"43926"}
418
+
419
+ !! minute in sub is nil or empty:
420
+ {"IdEvent"=>nil,
421
+ "Period"=>4,
422
+ "Reason"=>0,
423
+ "SubstitutePosition"=>3,
424
+ "IdPlayerOff"=>"483448",
425
+ "IdPlayerOn"=>"494626",
426
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Antonio NUSA"}],
427
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Andreas SCHJELDERUP"}],
428
+ "Minute"=>"",
429
+ "IdTeam"=>"43961"}
430
+
431
+ !! minute in sub is nil or empty:
432
+ {"IdEvent"=>nil,
433
+ "Period"=>4,
434
+ "Reason"=>0,
435
+ "SubstitutePosition"=>3,
436
+ "IdPlayerOff"=>"398588",
437
+ "IdPlayerOn"=>"477470",
438
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Alexander SORLOTH"}],
439
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Oscar BOBB"}],
440
+ "Minute"=>"",
441
+ "IdTeam"=>"43961"}
442
+
443
+ !! minute in sub is nil or empty:
444
+ {"IdEvent"=>nil,
445
+ "Period"=>4,
446
+ "Reason"=>0,
447
+ "SubstitutePosition"=>1,
448
+ "IdPlayerOff"=>"395516",
449
+ "IdPlayerOn"=>"400634",
450
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Cesar MONTES"}],
451
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Edson ALVAREZ"}],
452
+ "Minute"=>"",
453
+ "IdTeam"=>"43911"}
454
+
455
+ !! minute in sub is nil or empty:
456
+ {"IdEvent"=>nil,
457
+ "Period"=>4,
458
+ "Reason"=>0,
459
+ "SubstitutePosition"=>1,
460
+ "IdPlayerOff"=>"406280",
461
+ "IdPlayerOn"=>"419068",
462
+ "PlayerOffName"=>[{"Locale"=>"en-GB", "Description"=>"Sergino DEST"}],
463
+ "PlayerOnName"=>[{"Locale"=>"en-GB", "Description"=>"Giovanni REYNA"}],
464
+ "Minute"=>"",
465
+ "IdTeam"=>"43921"}
@@ -0,0 +1,91 @@
1
+
2
+
3
+ def build_team( h )
4
+
5
+ if h
6
+ name = desc( h['TeamName'] )
7
+
8
+ ## name = norm_team( name )
9
+
10
+ rec = {
11
+ id: h['IdTeam'],
12
+ name: name,
13
+ code: h['Abbreviation'],
14
+ country: h['IdCountry'], ## change to cc (country code) - why? why not?
15
+ }
16
+
17
+ rec
18
+ else ## assume nil - dummy record
19
+ rec = {
20
+ id: '<nil>',
21
+ name: '?',
22
+ code: '?', ## use nil - why? why not?
23
+ country: '?' ## use nil - why? why not?
24
+ }
25
+ rec
26
+ end
27
+ end
28
+
29
+
30
+
31
+
32
+ class Teams
33
+ def initialize
34
+ @recs = {}
35
+ end
36
+
37
+ def add_matches( matches )
38
+ ## note - if team nil - will (auto-)add nil team (<nil>,?,?,?)
39
+ matches.each do |m|
40
+ _add( build_team( m['Home'] ) )
41
+ _add( build_team( m['Away'] ) )
42
+ end
43
+ end
44
+
45
+
46
+ =begin
47
+ !! ASSERT FAILED - team records NOT matching -
48
+ {:id=>"44129",
49
+ :name=>"Vasco da Gama",
50
+ :code=>"VDG",
51
+ :country=>"BRA",
52
+ :count=>7}
53
+ !=
54
+ {:id=>"44129",
55
+ :name=>"Vasco da Gama",
56
+ :code=>"VAS",
57
+ :country=>"BRA"}
58
+ =end
59
+
60
+
61
+ def _add( new_rec )
62
+ rec = @recs[ new_rec[:id] ]
63
+ if rec.nil?
64
+ rec = new_rec
65
+ rec[:count] = 1 ## add counter - why? why not?
66
+ @recs[ new_rec[:id]] = new_rec
67
+ else
68
+ rec[:count] += 1
69
+
70
+ ## assert attributes equal - why? why not?
71
+ ## note - ignore code for now
72
+ ## new_rec[:code] == rec[:code] &&
73
+ assert( new_rec[:name] == rec[:name] &&
74
+ new_rec[:country] == rec[:country],
75
+ "team records NOT matching - #{rec.pretty_inspect} != #{new_rec.pretty_inspect}")
76
+ end
77
+ end
78
+
79
+
80
+ def as_json( id: false )
81
+ ## note - always remove code for now
82
+ if id
83
+ @recs.values
84
+ else
85
+ @recs.values.map { |rec| rec.except( :id ) }
86
+ end
87
+ end
88
+
89
+ def size() @recs.size; end
90
+
91
+ end # class Teams