ski_binding_calculator 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,41 +1,54 @@
1
1
  #weight [kg]
2
2
  #height [cm]
3
+ #Code A
3
4
  - !ruby/object:SkiBinding::Code
4
5
  weight: !ruby/range 10..13
5
- height: !ruby/range 1..148
6
+ height: ~
7
+ #Code B
6
8
  - !ruby/object:SkiBinding::Code
7
9
  weight: !ruby/range 14..17
8
- height: !ruby/range 1..148
10
+ height: ~
11
+ #Code C
9
12
  - !ruby/object:SkiBinding::Code
10
13
  weight: !ruby/range 18..21
11
- height: !ruby/range 1..148
14
+ height: ~
15
+ #Code D
12
16
  - !ruby/object:SkiBinding::Code
13
17
  weight: !ruby/range 22..25
14
- height: !ruby/range 1..148
18
+ height: ~
19
+ #Code E
15
20
  - !ruby/object:SkiBinding::Code
16
21
  weight: !ruby/range 26..30
17
- height: !ruby/range 1..148
22
+ height: ~
23
+ #Code F
18
24
  - !ruby/object:SkiBinding::Code
19
25
  weight: !ruby/range 31..35
20
- height: !ruby/range 1..148
26
+ height: ~
27
+ #Code G
21
28
  - !ruby/object:SkiBinding::Code
22
29
  weight: !ruby/range 36..41
23
- height: !ruby/range 1..148
30
+ height: ~
31
+ #Code H
24
32
  - !ruby/object:SkiBinding::Code
25
33
  weight: !ruby/range 42..48
26
34
  height: !ruby/range 1..148
35
+ #Code I
27
36
  - !ruby/object:SkiBinding::Code
28
37
  weight: !ruby/range 49..57
29
38
  height: !ruby/range 149..157
39
+ #Code J
30
40
  - !ruby/object:SkiBinding::Code
31
41
  weight: !ruby/range 58..66
32
42
  height: !ruby/range 158..166
43
+ #Code K
33
44
  - !ruby/object:SkiBinding::Code
34
45
  weight: !ruby/range 67..78
35
46
  height: !ruby/range 167..178
47
+ #Code L
36
48
  - !ruby/object:SkiBinding::Code
37
49
  weight: !ruby/range 79..94
38
50
  height: !ruby/range 179..194
51
+ #Code M
39
52
  - !ruby/object:SkiBinding::Code
40
53
  weight: !ruby/range
41
54
  begin: 95
@@ -3,72 +3,101 @@
3
3
  # forward_lean [Nm]
4
4
  -
5
5
  - !ruby/object:SkiBinding::Setting
6
- shoe_size_range: !ruby/range 1..250
6
+ shoe_size_range: !ruby/range 1..230
7
7
  z_value: 0.75
8
8
  twist: &turning_moment 8
9
- forward_lean: &forward_lean 29
10
- - !ruby/object:SkiBinding::Setting
9
+ forward_lean: &forward_lean 29
10
+ - !ruby/object:SkiBinding::Setting
11
+ shoe_size_range: !ruby/range 231..250
12
+ z_value: 0.75
13
+ twist: *turning_moment
14
+ forward_lean: *forward_lean
15
+ - !ruby/object:SkiBinding::Setting
11
16
  shoe_size_range: !ruby/range 251..270
12
17
  z_value: 0.75
13
18
  twist: *turning_moment
14
19
  forward_lean: *forward_lean
15
- - !ruby/object:SkiBinding::Setting
16
- shoe_size_range: ~
20
+ - !ruby/object:SkiBinding::Setting
21
+ shoe_size_range: !ruby/range 271..290
22
+ z_value: ~
23
+ twist: ~
24
+ forward_lean: ~
25
+ - !ruby/object:SkiBinding::Setting
26
+ shoe_size_range: !ruby/range 291..310
17
27
  z_value: ~
18
28
  twist: ~
19
29
  forward_lean: ~
20
- - !ruby/object:SkiBinding::Setting
21
- shoe_size_range: ~
30
+ - !ruby/object:SkiBinding::Setting
31
+ shoe_size_range: !ruby/range 311..330
22
32
  z_value: ~
23
33
  twist: ~
24
34
  forward_lean: ~
25
- - !ruby/object:SkiBinding::Setting
26
- shoe_size_range: ~
35
+ - !ruby/object:SkiBinding::Setting
36
+ shoe_size_range: !ruby/range 331..350
27
37
  z_value: ~
28
38
  twist: ~
29
39
  forward_lean: ~
30
- - !ruby/object:SkiBinding::Setting
31
- shoe_size_range: ~
40
+ - !ruby/object:SkiBinding::Setting
41
+ shoe_size_range: !ruby/range
42
+ begin: 351
43
+ end: .inf
32
44
  z_value: ~
33
45
  twist: ~
34
46
  forward_lean: ~
35
- -
47
+ -
36
48
  - !ruby/object:SkiBinding::Setting
37
- shoe_size_range: !ruby/range 1..250
38
- z_value: 1
49
+ shoe_size_range: !ruby/range 1..230
50
+ z_value: 1.0
39
51
  twist: &turning_moment 11
40
- forward_lean: &forward_lean 40
52
+ forward_lean: &forward_lean 40
53
+ - !ruby/object:SkiBinding::Setting
54
+ shoe_size_range: !ruby/range 231..250
55
+ z_value: 0.75
56
+ twist: *turning_moment
57
+ forward_lean: *forward_lean
41
58
  - !ruby/object:SkiBinding::Setting
42
59
  shoe_size_range: !ruby/range 251..270
43
- z_value: 1
60
+ z_value: 0.75
44
61
  twist: *turning_moment
45
62
  forward_lean: *forward_lean
46
63
  - !ruby/object:SkiBinding::Setting
47
64
  shoe_size_range: !ruby/range 271..290
48
65
  z_value: 0.75
49
66
  twist: *turning_moment
50
- forward_lean: *forward_lean
51
- - !ruby/object:SkiBinding::Setting
52
- shoe_size_range: ~
67
+ forward_lean: *forward_lean
68
+ - !ruby/object:SkiBinding::Setting
69
+ shoe_size_range: !ruby/range 291..310
53
70
  z_value: ~
54
71
  twist: ~
55
72
  forward_lean: ~
56
- - !ruby/object:SkiBinding::Setting
57
- shoe_size_range: ~
73
+ - !ruby/object:SkiBinding::Setting
74
+ shoe_size_range: !ruby/range 311..330
58
75
  z_value: ~
59
76
  twist: ~
60
77
  forward_lean: ~
61
- - !ruby/object:SkiBinding::Setting
62
- shoe_size_range: ~
78
+ - !ruby/object:SkiBinding::Setting
79
+ shoe_size_range: !ruby/range 331..350
63
80
  z_value: ~
64
81
  twist: ~
65
82
  forward_lean: ~
66
- -
67
83
  - !ruby/object:SkiBinding::Setting
68
- shoe_size_range: !ruby/range 1..250
84
+ shoe_size_range: !ruby/range
85
+ begin: 351
86
+ end: .inf
87
+ z_value: ~
88
+ twist: ~
89
+ forward_lean: ~
90
+ -
91
+ - !ruby/object:SkiBinding::Setting
92
+ shoe_size_range: !ruby/range 1..230
69
93
  z_value: 1.5
70
94
  twist: &turning_moment 14
71
95
  forward_lean: &forward_lean 52
96
+ - !ruby/object:SkiBinding::Setting
97
+ shoe_size_range: !ruby/range 231..250
98
+ z_value: 1.25
99
+ twist: *turning_moment
100
+ forward_lean: *forward_lean
72
101
  - !ruby/object:SkiBinding::Setting
73
102
  shoe_size_range: !ruby/range 251..270
74
103
  z_value: 1.25
@@ -76,30 +105,42 @@
76
105
  forward_lean: *forward_lean
77
106
  - !ruby/object:SkiBinding::Setting
78
107
  shoe_size_range: !ruby/range 271..290
79
- z_value: 1
108
+ z_value: 1.0
80
109
  twist: *turning_moment
81
110
  forward_lean: *forward_lean
82
- - !ruby/object:SkiBinding::Setting
83
- shoe_size_range: ~
111
+ - !ruby/object:SkiBinding::Setting
112
+ shoe_size_range: !ruby/range 291..310
84
113
  z_value: ~
85
114
  twist: ~
86
115
  forward_lean: ~
87
- - !ruby/object:SkiBinding::Setting
88
- shoe_size_range: ~
116
+ - !ruby/object:SkiBinding::Setting
117
+ shoe_size_range: !ruby/range 311..330
89
118
  z_value: ~
90
119
  twist: ~
91
120
  forward_lean: ~
92
- - !ruby/object:SkiBinding::Setting
93
- shoe_size_range: ~
121
+ - !ruby/object:SkiBinding::Setting
122
+ shoe_size_range: !ruby/range 331..350
123
+ z_value: ~
124
+ twist: ~
125
+ forward_lean: ~
126
+ - !ruby/object:SkiBinding::Setting
127
+ shoe_size_range: !ruby/range
128
+ begin: 351
129
+ end: .inf
94
130
  z_value: ~
95
131
  twist: ~
96
132
  forward_lean: ~
97
133
  -
98
134
  - !ruby/object:SkiBinding::Setting
99
- shoe_size_range: !ruby/range 1..250
100
- z_value: 1.75
135
+ shoe_size_range: !ruby/range 1..230
136
+ z_value: 2.0
101
137
  twist: &turning_moment 17
102
138
  forward_lean: &forward_lean 64
139
+ - !ruby/object:SkiBinding::Setting
140
+ shoe_size_range: !ruby/range 231..250
141
+ z_value: 1.75
142
+ twist: *turning_moment
143
+ forward_lean: *forward_lean
103
144
  - !ruby/object:SkiBinding::Setting
104
145
  shoe_size_range: !ruby/range 251..270
105
146
  z_value: 1.5
@@ -115,25 +156,37 @@
115
156
  z_value: 1.25
116
157
  twist: *turning_moment
117
158
  forward_lean: *forward_lean
118
- - !ruby/object:SkiBinding::Setting
119
- shoe_size_range: ~
159
+ - !ruby/object:SkiBinding::Setting
160
+ shoe_size_range: !ruby/range 311..330
161
+ z_value: ~
162
+ twist: ~
163
+ forward_lean: ~
164
+ - !ruby/object:SkiBinding::Setting
165
+ shoe_size_range: !ruby/range 331..350
120
166
  z_value: ~
121
167
  twist: ~
122
168
  forward_lean: ~
123
- - !ruby/object:SkiBinding::Setting
124
- shoe_size_range: ~
169
+ - !ruby/object:SkiBinding::Setting
170
+ shoe_size_range: !ruby/range
171
+ begin: 351
172
+ end: .inf
125
173
  z_value: ~
126
174
  twist: ~
127
175
  forward_lean: ~
128
176
  -
129
177
  - !ruby/object:SkiBinding::Setting
130
- shoe_size_range: !ruby/range 1..250
131
- z_value: 2.25
178
+ shoe_size_range: !ruby/range 1..230
179
+ z_value: 2.5
132
180
  twist: &turning_moment 20
133
181
  forward_lean: &forward_lean 75
134
182
  - !ruby/object:SkiBinding::Setting
135
- shoe_size_range: !ruby/range 251..270
136
- z_value: 2
183
+ shoe_size_range: !ruby/range 231..250
184
+ z_value: 2.25
185
+ twist: *turning_moment
186
+ forward_lean: *forward_lean
187
+ - !ruby/object:SkiBinding::Setting
188
+ shoe_size_range: !ruby/range 251..270
189
+ z_value: 2.0
137
190
  twist: *turning_moment
138
191
  forward_lean: *forward_lean
139
192
  - !ruby/object:SkiBinding::Setting
@@ -147,23 +200,35 @@
147
200
  twist: *turning_moment
148
201
  forward_lean: *forward_lean
149
202
  - !ruby/object:SkiBinding::Setting
150
- shoe_size_range: !ruby/range 311..330
203
+ shoe_size_range: !ruby/range 311..330
151
204
  z_value: 1.5
152
205
  twist: *turning_moment
153
206
  forward_lean: *forward_lean
154
- - !ruby/object:SkiBinding::Setting
155
- shoe_size_range: ~
207
+ - !ruby/object:SkiBinding::Setting
208
+ shoe_size_range: !ruby/range 331..350
209
+ z_value: ~
210
+ twist: ~
211
+ forward_lean: ~
212
+ - !ruby/object:SkiBinding::Setting
213
+ shoe_size_range: !ruby/range
214
+ begin: 351
215
+ end: .inf
156
216
  z_value: ~
157
217
  twist: ~
158
218
  forward_lean: ~
159
219
  -
160
220
  - !ruby/object:SkiBinding::Setting
161
- shoe_size_range: !ruby/range 1..250
162
- z_value: 2.75
221
+ shoe_size_range: !ruby/range 1..230
222
+ z_value: 3.0
163
223
  twist: &turning_moment 23
164
224
  forward_lean: &forward_lean 87
165
225
  - !ruby/object:SkiBinding::Setting
166
- shoe_size_range: !ruby/range 251..270
226
+ shoe_size_range: !ruby/range 231..250
227
+ z_value: 2.75
228
+ twist: *turning_moment
229
+ forward_lean: *forward_lean
230
+ - !ruby/object:SkiBinding::Setting
231
+ shoe_size_range: !ruby/range 251..270
167
232
  z_value: 2.5
168
233
  twist: *turning_moment
169
234
  forward_lean: *forward_lean
@@ -174,7 +239,7 @@
174
239
  forward_lean: *forward_lean
175
240
  - !ruby/object:SkiBinding::Setting
176
241
  shoe_size_range: !ruby/range 291..310
177
- z_value: 2
242
+ z_value: 2.0
178
243
  twist: *turning_moment
179
244
  forward_lean: *forward_lean
180
245
  - !ruby/object:SkiBinding::Setting
@@ -183,21 +248,31 @@
183
248
  twist: *turning_moment
184
249
  forward_lean: *forward_lean
185
250
  - !ruby/object:SkiBinding::Setting
186
- shoe_size_range: !ruby/range
187
- begin: 331
188
- end: .inf
251
+ shoe_size_range: !ruby/range 331..350
189
252
  z_value: 1.75
190
253
  twist: *turning_moment
191
254
  forward_lean: *forward_lean
255
+ - !ruby/object:SkiBinding::Setting
256
+ shoe_size_range: !ruby/range
257
+ begin: 351
258
+ end: .inf
259
+ z_value: ~
260
+ twist: ~
261
+ forward_lean: ~
192
262
  -
193
263
  - !ruby/object:SkiBinding::Setting
194
- shoe_size_range: !ruby/range 1..250
264
+ shoe_size_range: !ruby/range 1..230
265
+ z_value: ~
266
+ twist: ~
267
+ forward_lean: ~
268
+ - !ruby/object:SkiBinding::Setting
269
+ shoe_size_range: !ruby/range 231..250
195
270
  z_value: 3.5
196
271
  twist: &turning_moment 27
197
272
  forward_lean: &forward_lean 102
198
273
  - !ruby/object:SkiBinding::Setting
199
274
  shoe_size_range: !ruby/range 251..270
200
- z_value: 3
275
+ z_value: 3.0
201
276
  twist: *turning_moment
202
277
  forward_lean: *forward_lean
203
278
  - !ruby/object:SkiBinding::Setting
@@ -216,31 +291,41 @@
216
291
  twist: *turning_moment
217
292
  forward_lean: *forward_lean
218
293
  - !ruby/object:SkiBinding::Setting
219
- shoe_size_range: !ruby/range
220
- begin: 331
221
- end: .inf
222
- z_value: 2
294
+ shoe_size_range: !ruby/range 331..350
295
+ z_value: 2.0
223
296
  twist: *turning_moment
224
297
  forward_lean: *forward_lean
298
+ - !ruby/object:SkiBinding::Setting
299
+ shoe_size_range: !ruby/range
300
+ begin: 351
301
+ end: .inf
302
+ z_value: ~
303
+ twist: ~
304
+ forward_lean: ~
225
305
  -
226
306
  - !ruby/object:SkiBinding::Setting
227
- shoe_size_range: !ruby/range 1..250
228
- z_value: 3.5
229
- twist: &turning_moment 31
230
- forward_lean: &forward_lean 120
307
+ shoe_size_range: !ruby/range 1..230
308
+ z_value: ~
309
+ twist: ~
310
+ forward_lean: ~
311
+ - !ruby/object:SkiBinding::Setting
312
+ shoe_size_range: !ruby/range 231..250
313
+ z_value: ~
314
+ twist: ~
315
+ forward_lean: ~
231
316
  - !ruby/object:SkiBinding::Setting
232
317
  shoe_size_range: !ruby/range 251..270
233
318
  z_value: 3.5
234
- twist: *turning_moment
235
- forward_lean: *forward_lean
319
+ twist: &turning_moment 27
320
+ forward_lean: &forward_lean 102
236
321
  - !ruby/object:SkiBinding::Setting
237
322
  shoe_size_range: !ruby/range 271..290
238
- z_value: 3
323
+ z_value: 3.0
239
324
  twist: *turning_moment
240
325
  forward_lean: *forward_lean
241
326
  - !ruby/object:SkiBinding::Setting
242
327
  shoe_size_range: !ruby/range 291..310
243
- z_value: 3
328
+ z_value: 3.0
244
329
  twist: *turning_moment
245
330
  forward_lean: *forward_lean
246
331
  - !ruby/object:SkiBinding::Setting
@@ -249,26 +334,36 @@
249
334
  twist: *turning_moment
250
335
  forward_lean: *forward_lean
251
336
  - !ruby/object:SkiBinding::Setting
252
- shoe_size_range: !ruby/range
253
- begin: 331
254
- end: .inf
337
+ shoe_size_range: !ruby/range 331..350
255
338
  z_value: 2.5
256
339
  twist: *turning_moment
257
340
  forward_lean: *forward_lean
341
+ - !ruby/object:SkiBinding::Setting
342
+ shoe_size_range: !ruby/range
343
+ begin: 351
344
+ end: .inf
345
+ z_value: ~
346
+ twist: ~
347
+ forward_lean: ~
258
348
  -
259
349
  - !ruby/object:SkiBinding::Setting
260
- shoe_size_range: !ruby/range 1..250
261
- z_value: 3.5
262
- twist: &turning_moment 37
263
- forward_lean: &forward_lean 141
350
+ shoe_size_range: !ruby/range 1..230
351
+ z_value: ~
352
+ twist: ~
353
+ forward_lean: ~
354
+ - !ruby/object:SkiBinding::Setting
355
+ shoe_size_range: !ruby/range 231..250
356
+ z_value: ~
357
+ twist: ~
358
+ forward_lean: ~
264
359
  - !ruby/object:SkiBinding::Setting
265
360
  shoe_size_range: !ruby/range 251..270
266
361
  z_value: 4.5
267
- twist: *turning_moment
268
- forward_lean: *forward_lean
362
+ twist: &turning_moment 37
363
+ forward_lean: &forward_lean 141
269
364
  - !ruby/object:SkiBinding::Setting
270
365
  shoe_size_range: !ruby/range 271..290
271
- z_value: 4
366
+ z_value: 4.0
272
367
  twist: *turning_moment
273
368
  forward_lean: *forward_lean
274
369
  - !ruby/object:SkiBinding::Setting
@@ -282,26 +377,36 @@
282
377
  twist: *turning_moment
283
378
  forward_lean: *forward_lean
284
379
  - !ruby/object:SkiBinding::Setting
285
- shoe_size_range: !ruby/range
286
- begin: 331
287
- end: .inf
288
- z_value: 3
380
+ shoe_size_range: !ruby/range 331..350
381
+ z_value: 3.0
289
382
  twist: *turning_moment
290
383
  forward_lean: *forward_lean
384
+ - !ruby/object:SkiBinding::Setting
385
+ shoe_size_range: !ruby/range
386
+ begin: 351
387
+ end: .inf
388
+ z_value: ~
389
+ twist: ~
390
+ forward_lean: ~
291
391
  -
292
392
  - !ruby/object:SkiBinding::Setting
293
- shoe_size_range: !ruby/range 1..250
294
- z_value: 3.5
295
- twist: &turning_moment 43
296
- forward_lean: &forward_lean 165
393
+ shoe_size_range: !ruby/range 1..230
394
+ z_value: ~
395
+ twist: ~
396
+ forward_lean: ~
397
+ - !ruby/object:SkiBinding::Setting
398
+ shoe_size_range: !ruby/range 231..250
399
+ z_value: ~
400
+ twist: ~
401
+ forward_lean: ~
297
402
  - !ruby/object:SkiBinding::Setting
298
403
  shoe_size_range: !ruby/range 251..270
299
404
  z_value: 5.5
300
- twist: *turning_moment
301
- forward_lean: *forward_lean
405
+ twist: &turning_moment 43
406
+ forward_lean: &forward_lean 165
302
407
  - !ruby/object:SkiBinding::Setting
303
408
  shoe_size_range: !ruby/range 271..290
304
- z_value: 5
409
+ z_value: 5.0
305
410
  twist: *turning_moment
306
411
  forward_lean: *forward_lean
307
412
  - !ruby/object:SkiBinding::Setting
@@ -311,30 +416,40 @@
311
416
  forward_lean: *forward_lean
312
417
  - !ruby/object:SkiBinding::Setting
313
418
  shoe_size_range: !ruby/range 311..330
314
- z_value: 4
419
+ z_value: 4.0
420
+ twist: *turning_moment
421
+ forward_lean: *forward_lean
422
+ - !ruby/object:SkiBinding::Setting
423
+ shoe_size_range: !ruby/range 331..350
424
+ z_value: 3.5
315
425
  twist: *turning_moment
316
426
  forward_lean: *forward_lean
317
427
  - !ruby/object:SkiBinding::Setting
318
428
  shoe_size_range: !ruby/range
319
- begin: 331
429
+ begin: 351
320
430
  end: .inf
321
- z_value: 3.5
431
+ z_value: 3.0
322
432
  twist: *turning_moment
323
433
  forward_lean: *forward_lean
324
434
  -
325
435
  - !ruby/object:SkiBinding::Setting
326
- shoe_size_range: !ruby/range 1..250
327
- z_value: 3.5
328
- twist: &turning_moment 50
329
- forward_lean: &forward_lean 194
436
+ shoe_size_range: !ruby/range 1..230
437
+ z_value: ~
438
+ twist: ~
439
+ forward_lean: ~
440
+ - !ruby/object:SkiBinding::Setting
441
+ shoe_size_range: !ruby/range 231..250
442
+ z_value: ~
443
+ twist: ~
444
+ forward_lean: ~
330
445
  - !ruby/object:SkiBinding::Setting
331
446
  shoe_size_range: !ruby/range 251..270
332
447
  z_value: 6.5
333
- twist: *turning_moment
334
- forward_lean: *forward_lean
448
+ twist: &turning_moment 50
449
+ forward_lean: &forward_lean 194
335
450
  - !ruby/object:SkiBinding::Setting
336
451
  shoe_size_range: !ruby/range 271..290
337
- z_value: 6
452
+ z_value: 6.0
338
453
  twist: *turning_moment
339
454
  forward_lean: *forward_lean
340
455
  - !ruby/object:SkiBinding::Setting
@@ -344,30 +459,40 @@
344
459
  forward_lean: *forward_lean
345
460
  - !ruby/object:SkiBinding::Setting
346
461
  shoe_size_range: !ruby/range 311..330
347
- z_value: 5
462
+ z_value: 5.0
463
+ twist: *turning_moment
464
+ forward_lean: *forward_lean
465
+ - !ruby/object:SkiBinding::Setting
466
+ shoe_size_range: !ruby/range 331..350
467
+ z_value: 4.5
348
468
  twist: *turning_moment
349
469
  forward_lean: *forward_lean
350
470
  - !ruby/object:SkiBinding::Setting
351
471
  shoe_size_range: !ruby/range
352
- begin: 331
472
+ begin: 351
353
473
  end: .inf
354
- z_value: 4.5
474
+ z_value: 4.0
355
475
  twist: *turning_moment
356
476
  forward_lean: *forward_lean
357
477
  -
358
478
  - !ruby/object:SkiBinding::Setting
359
- shoe_size_range: !ruby/range 1..250
360
- z_value: 3.5
361
- twist: &turning_moment 58
362
- forward_lean: &forward_lean 229
479
+ shoe_size_range: !ruby/range 1..230
480
+ z_value: ~
481
+ twist: ~
482
+ forward_lean: ~
483
+ - !ruby/object:SkiBinding::Setting
484
+ shoe_size_range: !ruby/range 231..250
485
+ z_value: ~
486
+ twist: ~
487
+ forward_lean: ~
363
488
  - !ruby/object:SkiBinding::Setting
364
489
  shoe_size_range: !ruby/range 251..270
365
490
  z_value: 7.5
366
- twist: *turning_moment
367
- forward_lean: *forward_lean
491
+ twist: &turning_moment 58
492
+ forward_lean: &forward_lean 229
368
493
  - !ruby/object:SkiBinding::Setting
369
494
  shoe_size_range: !ruby/range 271..290
370
- z_value: 7
495
+ z_value: 7.0
371
496
  twist: *turning_moment
372
497
  forward_lean: *forward_lean
373
498
  - !ruby/object:SkiBinding::Setting
@@ -377,65 +502,85 @@
377
502
  forward_lean: *forward_lean
378
503
  - !ruby/object:SkiBinding::Setting
379
504
  shoe_size_range: !ruby/range 311..330
380
- z_value: 6
505
+ z_value: 6.0
506
+ twist: *turning_moment
507
+ forward_lean: *forward_lean
508
+ - !ruby/object:SkiBinding::Setting
509
+ shoe_size_range: !ruby/range 331..350
510
+ z_value: 5.5
381
511
  twist: *turning_moment
382
512
  forward_lean: *forward_lean
383
513
  - !ruby/object:SkiBinding::Setting
384
514
  shoe_size_range: !ruby/range
385
- begin: 331
515
+ begin: 351
386
516
  end: .inf
387
- z_value: 5.5
517
+ z_value: 5.0
388
518
  twist: *turning_moment
389
519
  forward_lean: *forward_lean
390
520
  -
391
521
  - !ruby/object:SkiBinding::Setting
392
- shoe_size_range: !ruby/range 1..250
393
- z_value: 3.5
394
- twist: &turning_moment 67
395
- forward_lean: &forward_lean 271
522
+ shoe_size_range: !ruby/range 1..230
523
+ z_value: ~
524
+ twist: ~
525
+ forward_lean: ~
526
+ - !ruby/object:SkiBinding::Setting
527
+ shoe_size_range: !ruby/range 231..250
528
+ z_value: ~
529
+ twist: ~
530
+ forward_lean: ~
396
531
  - !ruby/object:SkiBinding::Setting
397
532
  shoe_size_range: !ruby/range 251..270
398
- z_value: 7.5
399
- twist: *turning_moment
400
- forward_lean: *forward_lean
533
+ z_value: ~
534
+ twist: ~
535
+ forward_lean: ~
401
536
  - !ruby/object:SkiBinding::Setting
402
537
  shoe_size_range: !ruby/range 271..290
403
538
  z_value: 8.5
404
- twist: *turning_moment
405
- forward_lean: *forward_lean
539
+ twist: &turning_moment 67
540
+ forward_lean: &forward_lean 271
406
541
  - !ruby/object:SkiBinding::Setting
407
542
  shoe_size_range: !ruby/range 291..310
408
- z_value: 8
543
+ z_value: 8.0
409
544
  twist: *turning_moment
410
545
  forward_lean: *forward_lean
411
546
  - !ruby/object:SkiBinding::Setting
412
547
  shoe_size_range: !ruby/range 311..330
413
- z_value: 7
548
+ z_value: 7.0
549
+ twist: *turning_moment
550
+ forward_lean: *forward_lean
551
+ - !ruby/object:SkiBinding::Setting
552
+ shoe_size_range: !ruby/range 331..350
553
+ z_value: 6.5
414
554
  twist: *turning_moment
415
555
  forward_lean: *forward_lean
416
556
  - !ruby/object:SkiBinding::Setting
417
557
  shoe_size_range: !ruby/range
418
- begin: 331
558
+ begin: 351
419
559
  end: .inf
420
- z_value: 6.5
560
+ z_value: 6.0
421
561
  twist: *turning_moment
422
562
  forward_lean: *forward_lean
423
563
  -
424
564
  - !ruby/object:SkiBinding::Setting
425
- shoe_size_range: !ruby/range 1..250
426
- z_value: 3.5
427
- twist: &turning_moment 78
428
- forward_lean: &forward_lean 320
565
+ shoe_size_range: !ruby/range 1..230
566
+ z_value: ~
567
+ twist: ~
568
+ forward_lean: ~
569
+ - !ruby/object:SkiBinding::Setting
570
+ shoe_size_range: !ruby/range 231..250
571
+ z_value: ~
572
+ twist: ~
573
+ forward_lean: ~
429
574
  - !ruby/object:SkiBinding::Setting
430
575
  shoe_size_range: !ruby/range 251..270
431
- z_value: 7.5
432
- twist: *turning_moment
433
- forward_lean: *forward_lean
576
+ z_value: ~
577
+ twist: ~
578
+ forward_lean: ~
434
579
  - !ruby/object:SkiBinding::Setting
435
580
  shoe_size_range: !ruby/range 271..290
436
- z_value: 10
437
- twist: *turning_moment
438
- forward_lean: *forward_lean
581
+ z_value: 10.0
582
+ twist: &turning_moment 78
583
+ forward_lean: &forward_lean 320
439
584
  - !ruby/object:SkiBinding::Setting
440
585
  shoe_size_range: !ruby/range 291..310
441
586
  z_value: 9.5
@@ -446,43 +591,101 @@
446
591
  z_value: 8.5
447
592
  twist: *turning_moment
448
593
  forward_lean: *forward_lean
594
+ - !ruby/object:SkiBinding::Setting
595
+ shoe_size_range: !ruby/range 331..350
596
+ z_value: 8.0
597
+ twist: *turning_moment
598
+ forward_lean: *forward_lean
449
599
  - !ruby/object:SkiBinding::Setting
450
600
  shoe_size_range: !ruby/range
451
- begin: 331
601
+ begin: 351
452
602
  end: .inf
453
- z_value: 8
603
+ z_value: 7.5
454
604
  twist: *turning_moment
455
605
  forward_lean: *forward_lean
456
606
  -
457
607
  - !ruby/object:SkiBinding::Setting
458
- shoe_size_range: !ruby/range 1..250
459
- z_value: 3.5
608
+ shoe_size_range: !ruby/range 1..230
609
+ z_value: ~
610
+ twist: ~
611
+ forward_lean: ~
612
+ - !ruby/object:SkiBinding::Setting
613
+ shoe_size_range: !ruby/range 231..250
614
+ z_value: ~
615
+ twist: ~
616
+ forward_lean: ~
617
+ - !ruby/object:SkiBinding::Setting
618
+ shoe_size_range: !ruby/range 251..270
619
+ z_value: ~
620
+ twist: ~
621
+ forward_lean: ~
622
+ - !ruby/object:SkiBinding::Setting
623
+ shoe_size_range: !ruby/range 271..290
624
+ z_value: 11.5
460
625
  twist: &turning_moment 91
461
626
  forward_lean: &forward_lean 380
462
627
  - !ruby/object:SkiBinding::Setting
463
- shoe_size_range: !ruby/range 251..270
464
- z_value: 7.5
628
+ shoe_size_range: !ruby/range 291..310
629
+ z_value: 11.0
465
630
  twist: *turning_moment
466
631
  forward_lean: *forward_lean
467
632
  - !ruby/object:SkiBinding::Setting
468
- shoe_size_range: !ruby/range 271..290
469
- z_value: 11.5
633
+ shoe_size_range: !ruby/range 311..330
634
+ z_value: 10.0
470
635
  twist: *turning_moment
471
636
  forward_lean: *forward_lean
472
637
  - !ruby/object:SkiBinding::Setting
473
- shoe_size_range: !ruby/range 291..310
474
- z_value: 11
638
+ shoe_size_range: !ruby/range 331..350
639
+ z_value: 9.5
475
640
  twist: *turning_moment
476
641
  forward_lean: *forward_lean
642
+ - !ruby/object:SkiBinding::Setting
643
+ shoe_size_range: !ruby/range
644
+ begin: 351
645
+ end: .inf
646
+ z_value: 9.0
647
+ twist: *turning_moment
648
+ forward_lean: *forward_lean
649
+ -
650
+ - !ruby/object:SkiBinding::Setting
651
+ shoe_size_range: !ruby/range 1..230
652
+ z_value: ~
653
+ twist: ~
654
+ forward_lean: ~
655
+ - !ruby/object:SkiBinding::Setting
656
+ shoe_size_range: !ruby/range 231..250
657
+ z_value: ~
658
+ twist: ~
659
+ forward_lean: ~
660
+ - !ruby/object:SkiBinding::Setting
661
+ shoe_size_range: !ruby/range 251..270
662
+ z_value: ~
663
+ twist: ~
664
+ forward_lean: ~
665
+ - !ruby/object:SkiBinding::Setting
666
+ shoe_size_range: !ruby/range 271..290
667
+ z_value: ~
668
+ twist: ~
669
+ forward_lean: ~
670
+ - !ruby/object:SkiBinding::Setting
671
+ shoe_size_range: !ruby/range 291..310
672
+ z_value: ~
673
+ twist: ~
674
+ forward_lean: ~
477
675
  - !ruby/object:SkiBinding::Setting
478
676
  shoe_size_range: !ruby/range 311..330
479
- z_value: 10
677
+ z_value: 12.0
678
+ twist: &turning_moment 105
679
+ forward_lean: &forward_lean 452
680
+ - !ruby/object:SkiBinding::Setting
681
+ shoe_size_range: !ruby/range 331..350
682
+ z_value: 11.0
480
683
  twist: *turning_moment
481
684
  forward_lean: *forward_lean
482
685
  - !ruby/object:SkiBinding::Setting
483
686
  shoe_size_range: !ruby/range
484
- begin: 331
687
+ begin: 351
485
688
  end: .inf
486
- z_value: 9.5
689
+ z_value: 10.5
487
690
  twist: *turning_moment
488
691
  forward_lean: *forward_lean
@@ -3,36 +3,89 @@ require 'ski_binding_calculator/config_loader'
3
3
  class SkiBinding::Calculator
4
4
  extend SkiBinding::ConfigLoader
5
5
 
6
- def self.setting(person)
7
- code = self.binding_code(person)
8
- self.binding_setting(code, person)
6
+ def self.setting(attrs)
7
+ attrs = self.prep_attributes(attrs)
8
+ attrs = self.age(attrs)
9
+ attrs = self.validate_type(attrs)
10
+ code = self.binding_code(attrs)
11
+ self.binding_setting(attrs, code)
9
12
  end
10
13
 
11
14
  private
12
-
13
- def self.binding_code(person)
15
+ def self.prep_attributes(attrs)
16
+ hashy = {}
17
+ hashy[:weight] = attrs[:weight].to_f || attrs["weight"].to_f
18
+ if hashy[:weight] < 10
19
+ raise ArgumentError, "Weight must be at least 10kg"
20
+ end
21
+ hashy[:height] = attrs[:height].to_f || attrs["height"].to_f
22
+ hashy[:shoe_size] = attrs[:shoe_size].to_f || attrs["shoe_size"].to_f
23
+ hashy[:birthday] = attrs[:birthday] || attrs["birthdate"]
24
+ hashy[:type] = attrs[:type] || attrs["type"]
25
+ attrs = hashy
26
+ attrs
27
+ end
28
+
29
+ def self.age(attrs)
30
+ birthday = Date.parse(attrs[:birthday])
31
+ now = Date.today
32
+ age = now.year - birthday.year
33
+ age -= ((now.month > birthday.month ||
34
+ (now.month == birthday.month && now.day >= birthday.day)) ? 0 : 1)
35
+ attrs.delete(:birthday)
36
+ attrs[:age] = age
37
+ attrs
38
+ end
39
+
40
+ def self.validate_type(attrs)
41
+ type_string = attrs[:type]
42
+ types = {"Type1-" => -1, "Type1" => 0, "Type2" => 1,
43
+ "Type3" => 2, "Type3+" => 3}
44
+ keys = types.keys
45
+ if keys.include?(type_string)
46
+ attrs[:type] = types[type_string]
47
+ else
48
+ raise ArgumentError, "You have entered an invalid type."
49
+ end
50
+ attrs
51
+ end
52
+
53
+ def self.binding_code(attrs)
14
54
  code = -1
15
55
  self.load_binding_codes.each_with_index do |c,i|
16
- code = i
17
- break if c.weight.include?(person.weight) ||
18
- c.height.include?(person.height)
56
+ if c.height.nil?
57
+ if c.weight.include?(attrs[:weight])
58
+ code = i
59
+ break
60
+ end
61
+ else
62
+ if c.weight.include?(attrs[:weight]) || c.height.include?(attrs[:height])
63
+ code = i
64
+ break
65
+ end
66
+ end
19
67
  end
20
- unless person.weight < 13
21
- code += person.type
22
- if person.age >= 50 || person.age < 10
68
+ if code == -1
69
+ raise ArgumentError, "You have entered invalid weight and/or height"
70
+ end
71
+ unless attrs[:weight] < 13
72
+ code += attrs[:type]
73
+ if attrs[:age] >= 50 || attrs[:age] < 10
23
74
  code -= 1
24
75
  end
25
76
  end
26
77
  code
27
78
  end
28
-
29
- def self.binding_setting(code, person)
79
+
80
+ def self.binding_setting(attrs, code)
30
81
  settings = self.load_binding_settings(code)
31
82
  settings.each do |s|
32
- if s.shoe_size_range.include?(person.shoe_size)
33
- return {"z_value" => s.z_value,
34
- "twist" => s.twist,
35
- "forward_lean" => s.forward_lean}
83
+ if s.shoe_size_range.include?(attrs[:shoe_size])
84
+ unless s.z_value.nil?
85
+ return {"z_value" => s.z_value}
86
+ else
87
+ raise ArgumentError, "Please calculate z-index by hand."
88
+ end
36
89
  end
37
90
  end
38
91
  end
@@ -3,4 +3,3 @@ require 'ski_binding_calculator/calculator'
3
3
  require 'ski_binding_calculator/config_loader'
4
4
  require 'ski_binding_calculator/code'
5
5
  require 'ski_binding_calculator/setting'
6
- require 'ski_binding_calculator/person'
@@ -1,11 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'ski_binding_calculator'
4
- s.version = '0.5.2'
4
+ s.version = '0.6.0'
5
5
  s.date = '2013-08-05'
6
6
  s.summary = "Ski Binding Calculator"
7
- s.description = "calculate the z-value, forward pressure and turning
8
- moment according to ISO 11088."
7
+ s.description = "Calculates the z-value according to ISO 11088."
9
8
  s.authors = ["Jonas Ruef, Felix Langenegger"]
10
9
  s.email = 'support@fadendaten.ch'
11
10
  s.homepage = 'http://fadendaten.ch'
@@ -14,6 +13,7 @@ Gem::Specification.new do |s|
14
13
  s.add_development_dependency "rspec", "~> 2.14.1"
15
14
  s.add_development_dependency "spork", "~> 0.9.2"
16
15
  s.add_development_dependency "simplecov", "~> 0.7.1"
16
+ s.add_development_dependency "timecop", "~> 0.6.3"
17
17
 
18
18
  s.files = Dir.glob("{config,lib,spec}/**/*")
19
19
  s.files += %w(Rakefile ski_binding_calculator.gemspec)
@@ -1,11 +1,15 @@
1
1
  require 'spec_helper'
2
+ require 'timecop'
2
3
 
3
4
  describe SkiBinding::Calculator do
4
5
  before(:all) do
5
- @calculator = SkiBinding::Calculator.new
6
- hash = {:type => "Type2", :weight => 70,
7
- :height => 170, :shoe_size => 315, :age => 30}
8
- @person = SkiBinding::Person.new(hash)
6
+ @hash = {:type => "Type2",
7
+ :weight => "70",
8
+ :height => "170",
9
+ :shoe_size => "315",
10
+ :birthday => "1983-01-01"}
11
+ #We freeze time so birthday will always be 30 years back
12
+ Timecop.freeze(2013, 8, 13)
9
13
  end
10
14
 
11
15
  describe "#new" do
@@ -14,53 +18,130 @@ describe SkiBinding::Calculator do
14
18
  end
15
19
  end
16
20
 
17
- describe "#setting" do
18
- it "returns a valid setting" do
19
- SkiBinding::Calculator.setting(@person).should ==
20
- {"z_value"=>6, "twist"=>58, "forward_lean"=>229}
21
+ describe "#prep_attributes" do
22
+ it "returns a valid hash" do
23
+ expected_hash = {:type => "Type2",
24
+ :weight => 70.0,
25
+ :height => 170.0,
26
+ :shoe_size => 315.0,
27
+ :birthday => "1983-01-01"}
28
+ SkiBinding::Calculator.prep_attributes(@hash).should == expected_hash
29
+ end
30
+
31
+ it "returns argument error if weight < 10kg" do
32
+ @hash[:weight] = "9"
33
+ expect { SkiBinding::Calculator.prep_attributes(@hash) }
34
+ .to raise_error(ArgumentError, "Weight must be at least 10kg")
35
+ @hash[:weight] = "70"
36
+ end
37
+ end
38
+
39
+ describe "#age" do
40
+ before(:all) do
41
+ @preped_hash = SkiBinding::Calculator.prep_attributes(@hash)
42
+ end
43
+
44
+ it "returns a hash with an age" do
45
+ result = SkiBinding::Calculator.age(@preped_hash)
46
+ result[:age].should == 30
21
47
  end
22
48
  end
23
49
 
50
+ describe "#validate_type" do
51
+ before :all do
52
+ preped_hash = SkiBinding::Calculator.prep_attributes(@hash)
53
+ @aged_hash = SkiBinding::Calculator.age(preped_hash)
54
+ end
55
+
56
+ it "sets \"Type2\" to 1" do
57
+ result = SkiBinding::Calculator.validate_type(@aged_hash)
58
+ result[:type].should == 1
59
+ end
60
+
61
+ it "raises argument error on type \"unknown\"" do
62
+ wrong_aged_hash = {:type => "unknown",
63
+ :weight => 70,
64
+ :height => 170,
65
+ :shoe_size => 315,
66
+ :age => 30}
67
+ expect { SkiBinding::Calculator.validate_type(wrong_aged_hash) }
68
+ .to raise_error(ArgumentError, "You have entered an invalid type.")
69
+ end
70
+ end
71
+
72
+
24
73
  describe "#binding_code" do
74
+ before :each do
75
+ preped_hash = SkiBinding::Calculator.prep_attributes(@hash)
76
+ aged_hash = SkiBinding::Calculator.age(preped_hash)
77
+ @type_validated_hash = SkiBinding::Calculator.validate_type(aged_hash)
78
+ end
79
+
25
80
  it "returns a valid code" do
26
- SkiBinding::Calculator.binding_code(@person).should == 11
81
+ SkiBinding::Calculator.binding_code(@type_validated_hash).should == 11
82
+ end
83
+
84
+ it "returns unchanged code if weight less than 13kg" do
85
+ # because we set "Type2" the code would be changed by 1
86
+ @type_validated_hash[:weight] = 12
87
+ SkiBinding::Calculator.binding_code(@type_validated_hash).should == 0
88
+ end
89
+
90
+ it "raises argumentError if no code was found" do
91
+ @type_validated_hash[:weight] = -1
92
+ @type_validated_hash[:height] = -1
93
+ expect { SkiBinding::Calculator.binding_code(@type_validated_hash) }
94
+ .to raise_error(ArgumentError, "You have entered invalid weight and/or height")
27
95
  end
28
96
 
29
- context "returns code one less if age >= 50" do
97
+ context "returns code one less if age >= 50 || age < 10" do
30
98
  before :each do
31
- @code = SkiBinding::Calculator.binding_code(@person)
99
+ preped_hash = SkiBinding::Calculator.prep_attributes(@hash)
100
+ aged_hash = SkiBinding::Calculator.age(preped_hash)
101
+ @type_validated_hash_age_context = SkiBinding::Calculator.validate_type(aged_hash)
102
+ @code = SkiBinding::Calculator.binding_code(@type_validated_hash_age_context)
32
103
  end
33
104
 
34
105
  it "age is 50" do
35
- hash = {:type => "Type2", :weight => 70,
36
- :height => 170, :shoe_size => 315, :age => 50}
37
- person = SkiBinding::Person.new(hash)
38
- lambda { @code = SkiBinding::Calculator.binding_code(person) }
39
- .should change{@code}.by(-1)
106
+ @type_validated_hash_age_context[:age] = 50
107
+ lambda { @code = SkiBinding::Calculator.binding_code(@type_validated_hash_age_context) }
108
+ .should change{@code}.by(-1)
40
109
  end
41
110
 
42
111
  it "age is 51" do
43
- hash = {:type => "Type2", :weight => 70,
44
- :height => 170, :shoe_size => 315, :age => 51}
45
- person = SkiBinding::Person.new(hash)
46
- lambda { @code = SkiBinding::Calculator.binding_code(person) }
112
+ @type_validated_hash_age_context[:age] = 51
113
+ lambda { @code = SkiBinding::Calculator.binding_code(@type_validated_hash_age_context) }
47
114
  .should change{@code}.by(-1)
48
115
  end
49
116
  end
117
+ end
118
+
119
+ describe "#binding_setting" do
120
+ before :each do
121
+ preped_hash = SkiBinding::Calculator.prep_attributes(@hash)
122
+ aged_hash = SkiBinding::Calculator.age(preped_hash)
123
+ @type_validated_hash = SkiBinding::Calculator.validate_type(aged_hash)
124
+ end
50
125
 
51
- it "returns unchanged code if weight less than 13kg" do
52
- # because we set "Type2" the code would be changed by 1
53
- hash = {:type => "Type2", :weight => 12,
54
- :height => 147, :shoe_size => 249, :age => 30}
55
- @person = SkiBinding::Person.new(hash)
56
- SkiBinding::Calculator.binding_code(@person).should == 0
126
+ it "returns a valid setting" do
127
+ SkiBinding::Calculator.binding_setting(@type_validated_hash, 11).should ==
128
+ {"z_value"=>6}
129
+ end
130
+
131
+ it "raises argument error if no settings found" do
132
+ expect { SkiBinding::Calculator.binding_setting(@type_validated_hash, 0) }
133
+ .to raise_error(ArgumentError, "Please calculate z-index by hand.")
57
134
  end
58
135
  end
59
136
 
60
- describe "#binding_setting" do
137
+ describe "#setting" do
61
138
  it "returns a valid setting" do
62
- SkiBinding::Calculator.binding_setting(11, @person).should ==
63
- {"z_value"=>6, "twist"=>58, "forward_lean"=>229}
139
+ SkiBinding::Calculator.setting(@hash).should ==
140
+ {"z_value"=>6}
64
141
  end
65
142
  end
143
+
144
+ after(:all) do
145
+ Timecop.return
146
+ end
66
147
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe "ConfigLoader" do
4
4
 
5
5
  before(:all) do
6
- @range = 0..14 #cause 15 codes
6
+ @range = 0..15 #cause 16 settings
7
7
  @dummy_class = DummyClass.new
8
8
  @dummy_class.extend(SkiBinding::ConfigLoader)
9
9
  end
@@ -61,7 +61,7 @@ describe "ConfigLoader" do
61
61
 
62
62
  it "has 6 settings" do
63
63
  @settings_all_codes.each do |s|
64
- s.size.should == 6
64
+ s.size.should == 8
65
65
  end
66
66
  end
67
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ski_binding_calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -59,8 +59,23 @@ dependencies:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.7.1
62
- description: ! "calculate the z-value, forward pressure and turning\n moment
63
- according to ISO 11088."
62
+ - !ruby/object:Gem::Dependency
63
+ name: timecop
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 0.6.3
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.6.3
78
+ description: Calculates the z-value according to ISO 11088.
64
79
  email: support@fadendaten.ch
65
80
  executables: []
66
81
  extensions: []
@@ -71,14 +86,12 @@ files:
71
86
  - lib/ski_binding_calculator/calculator.rb
72
87
  - lib/ski_binding_calculator/code.rb
73
88
  - lib/ski_binding_calculator/config_loader.rb
74
- - lib/ski_binding_calculator/person.rb
75
89
  - lib/ski_binding_calculator/setting.rb
76
90
  - lib/ski_binding_calculator/ski_binding.rb
77
91
  - lib/ski_binding_calculator.rb
78
92
  - spec/lib/calculator_spec.rb
79
93
  - spec/lib/code_spec.rb
80
94
  - spec/lib/config_loader_spec.rb
81
- - spec/lib/person_spec.rb
82
95
  - spec/lib/setting_spec.rb
83
96
  - spec/spec_helper.rb
84
97
  - Rakefile
@@ -1,20 +0,0 @@
1
- class SkiBinding::Person
2
- attr_reader :type, :weight, :height, :shoe_size, :age
3
-
4
- def initialize(values_hash)
5
- @type = validate_type(values_hash["type"] || values_hash[:type])
6
- @weight = values_hash["weight"] || values_hash[:weight]
7
- @height = values_hash["height"] || values_hash[:height]
8
- @shoe_size = values_hash["shoe_size"] || values_hash[:shoe_size]
9
- @age = values_hash["age"] || values_hash[:age]
10
- end
11
-
12
- private
13
-
14
- def validate_type(type)
15
- types = {"Type1-" => -1, "Type1" => 0, "Type2" => 1,
16
- "Type3" => 2, "Type3+" => 3}
17
- keys = types.keys
18
- types[type] if keys.include?(type)
19
- end
20
- end
@@ -1,58 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe SkiBinding::Person do
4
- before :all do
5
- @hash = {:type => "Type2",
6
- :weight => 70,
7
- :height => 170,
8
- :shoe_size => 315,
9
- :age => 30}
10
- end
11
-
12
- describe "#new" do
13
- it "should return a Person class" do
14
- SkiBinding::Person.new(@hash).class.should == SkiBinding::Person
15
- end
16
- end
17
-
18
- context "instantiated Person class" do
19
- before :all do
20
- @person = SkiBinding::Person.new(@hash)
21
- end
22
-
23
- it "has attribute type" do
24
- @person.should respond_to :type
25
- end
26
-
27
- it "has attribute weight" do
28
- @person.should respond_to :weight
29
- end
30
-
31
- it "has attribute heigth" do
32
- @person.should respond_to :height
33
- end
34
-
35
- it "has attribute shoe_size" do
36
- @person.should respond_to :shoe_size
37
- end
38
-
39
- it "has attribute age" do
40
- @person.should respond_to :age
41
- end
42
-
43
- describe "validates type" do
44
- it "sets \"Type2\" to 1" do
45
- @person.type.should == 1
46
- end
47
-
48
- it "sets type \"unknown\" to nil" do
49
- hash = {:type => "unknown",
50
- :weight => 70,
51
- :height => 170,
52
- :shoe_size => 315,
53
- :age => 30}
54
- SkiBinding::Person.new(hash).type.should == nil
55
- end
56
- end
57
- end
58
- end