ski_binding_calculator 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,18 +20,22 @@ class SkiBinding::Calculator
20
20
  end
21
21
  hashy[:height] = attrs[:height].to_f || attrs["height"].to_f
22
22
  hashy[:sole_length] = attrs[:sole_length].to_f || attrs["sole_length"].to_f
23
- hashy[:birthday] = attrs[:birthday] || attrs["birthdate"]
23
+ hashy[:birthday_year] = attrs[:birthday_year].to_i || attrs["birthday_year"].to_i
24
+ hashy[:birthday_month] = attrs[:birthday_month].to_i || attrs["birthday_month"].to_i
25
+ hashy[:birthday_day] = attrs[:birthday_day].to_i || attrs["birthday_day"].to_i
24
26
  hashy[:type] = attrs[:type] || attrs["type"]
25
27
  hashy
26
28
  end
27
29
 
28
30
  def self.age(attrs)
29
- birthday = Date.parse(attrs[:birthday])
31
+ birthday = Date.new(attrs[:birthday_year], attrs[:birthday_month], attrs[:birthday_day])
30
32
  now = Date.today
31
33
  age = now.year - birthday.year
32
34
  age -= ((now.month > birthday.month ||
33
35
  (now.month == birthday.month && now.day >= birthday.day)) ? 0 : 1)
34
- attrs.delete(:birthday)
36
+ attrs.delete(:birthday_year)
37
+ attrs.delete(:birthday_month)
38
+ attrs.delete(:birthday_day)
35
39
  attrs[:age] = age
36
40
  attrs
37
41
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'ski_binding_calculator'
4
- s.version = '0.6.6'
4
+ s.version = '0.6.7'
5
5
  s.summary = "Ski Binding Calculator"
6
6
  s.description = "Calculates the z-value according to ISO 11088."
7
7
  s.authors = ["Jonas Ruef, Felix Langenegger"]
@@ -11,14 +11,18 @@ describe SkiBinding::Calculator do
11
11
  :weight => "70",
12
12
  :height => "170",
13
13
  :sole_length => "315",
14
- :birthday => "1983-01-01" }
14
+ :birthday_year => "1983",
15
+ :birthday_month => "01",
16
+ :birthday_day => "01" }
15
17
  end
16
18
  subject(:expected_preped) do
17
19
  { :type => "Type2",
18
20
  :weight => 70.0,
19
21
  :height => 170.0,
20
22
  :sole_length => 315.0,
21
- :birthday => "1983-01-01" }
23
+ :birthday_year => 1983,
24
+ :birthday_month => 1,
25
+ :birthday_day => 1 }
22
26
  end
23
27
  subject(:expected_aged) do
24
28
  { :type => "Type2",
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.6.6
4
+ version: 0.6.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: