diff --git a/furlong.rb b/furlong.rb index 9b7e2b4..27c0d95 100644 --- a/furlong.rb +++ b/furlong.rb @@ -1,7 +1,12 @@ class Furlong KM_PER_MILE = 1.60934 + FURLONG_PER_KM = 0.201168 def miles_to_kilometers(miles) miles * KM_PER_MILE end -end \ No newline at end of file + + def furlongs_to_kilometers(furlong) + furlong * FURLONG_PER_KM + end +end diff --git a/furlong_spec.rb b/furlong_spec.rb index 053ebfd..87f5d09 100644 --- a/furlong_spec.rb +++ b/furlong_spec.rb @@ -4,7 +4,7 @@ describe Furlong do let(:calculator) { Furlong.new } - + it "converts 1 mile to 1.60934 km" do subject.miles_to_kilometers(1).should be_within(0.0001).of(1.60934) end @@ -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 -end \ No newline at end of file + + it "converts 1 furlong to 0.201168 km" do + subject.furlongs_to_kilometers(1).should be_within(0.0001).of(0.201168) + end + + it "converts 5 furlongs to approx. a km" do + subject.furlongs_to_kilometers(5).should be_within(0.0001).of(1.00584) + end +end