diff --git a/furlong.rb b/furlong.rb index 9b7e2b4..954d5d5 100644 --- a/furlong.rb +++ b/furlong.rb @@ -1,7 +1,13 @@ class Furlong KM_PER_MILE = 1.60934 + FURLONG_PER_KM = 0.201168 + def miles_to_kilometers(miles) miles * KM_PER_MILE end + + def furlongs_to_km(furlongs) + furlongs * FURLONG_PER_KM + end end \ No newline at end of file diff --git a/furlong_spec.rb b/furlong_spec.rb index 053ebfd..c9ce078 100644 --- a/furlong_spec.rb +++ b/furlong_spec.rb @@ -12,4 +12,12 @@ it "converts a marathon: 26.219 miles to 42.194988 km" do subject.miles_to_kilometers(26.219).should be_within(0.001).of(42.194988) end + + it "converts 1 furlong to 0.201168 km" do + calculator.furlongs_to_km(1).should be_within(0.0001).of(0.201168) + end + + it "converts 15 furlong to 3.01752 km" do + calculator.furlongs_to_km(15).should be_within(0.001).of(3.01752) + end end \ No newline at end of file