farski-systeme 0.2.0 → 0.2.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.
- data/VERSION.yml +1 -1
- data/lib/systeme/imperial.rb +5 -5
- data/test/imperial_test.rb +10 -18
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/systeme/imperial.rb
CHANGED
@@ -23,16 +23,16 @@ module Systeme
|
|
23
23
|
IMPERIAL_MEASURES['length'][:units] << { :unit => "fathom", :factor => 6 }
|
24
24
|
IMPERIAL_MEASURES['length'][:units] << { :unit => "cable", :factor => 608 }
|
25
25
|
IMPERIAL_MEASURES['length'][:units] << { :unit => "nautical_mile", :factor => 6080, :aliases => ["NM", "nmi", "M"] }
|
26
|
-
IMPERIAL_MEASURES['length'][:units] << { :unit => "link", :factor => (66/100), :aliases => ["lnk"] }
|
27
|
-
IMPERIAL_MEASURES['length'][:units] << { :unit => "rod", :factor => (66/4), :aliases => ["perch", "perches", "pole", "lug"] }
|
26
|
+
IMPERIAL_MEASURES['length'][:units] << { :unit => "link", :factor => (66.0/100), :aliases => ["lnk"] }
|
27
|
+
IMPERIAL_MEASURES['length'][:units] << { :unit => "rod", :factor => (66.0/4), :aliases => ["perch", "perches", "pole", "lug"] }
|
28
28
|
IMPERIAL_MEASURES['length'][:units] << { :unit => "chain", :factor => 66 }
|
29
29
|
|
30
30
|
IMPERIAL_MEASURES['weight'] = Hash.new
|
31
31
|
IMPERIAL_MEASURES['weight'][:si] = 0.45359237
|
32
32
|
IMPERIAL_MEASURES['weight'][:units] = Array.new
|
33
|
-
IMPERIAL_MEASURES['weight'][:units] << { :unit => "grain", :factor => (1/7000) }
|
34
|
-
IMPERIAL_MEASURES['weight'][:units] << { :unit => "drachm", :factor => (1/256) }
|
35
|
-
IMPERIAL_MEASURES['weight'][:units] << { :unit => "ounce", :factor => (1/16), :aliases => ["oz"] }
|
33
|
+
IMPERIAL_MEASURES['weight'][:units] << { :unit => "grain", :factor => (1.0/7000) }
|
34
|
+
IMPERIAL_MEASURES['weight'][:units] << { :unit => "drachm", :factor => (1.0/256) }
|
35
|
+
IMPERIAL_MEASURES['weight'][:units] << { :unit => "ounce", :factor => (1.0/16), :aliases => ["oz"] }
|
36
36
|
IMPERIAL_MEASURES['weight'][:units] << { :unit => "pound", :factor => 1, :aliases => ["lb", "lbm", "lbs"] }
|
37
37
|
IMPERIAL_MEASURES['weight'][:units] << { :unit => "stone", :factor => 14, :aliases => ["st"] }
|
38
38
|
IMPERIAL_MEASURES['weight'][:units] << { :unit => "quarter", :factor => 28 }
|
data/test/imperial_test.rb
CHANGED
@@ -1,24 +1,16 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper'
|
2
2
|
|
3
3
|
class ImperialTest < Test::Unit::TestCase
|
4
|
-
should "
|
5
|
-
|
6
|
-
# assert_equal 1, 1.ft
|
7
|
-
# assert_equal 1, 1.lb
|
4
|
+
should "express imperial unit in metric base unit" do
|
5
|
+
assert_in_delta 0.9144, 1.yard, 0.0001
|
8
6
|
end
|
9
|
-
#
|
10
|
-
# should "express non-base unit value in the base unit" do
|
11
|
-
# assert_equal 3, 1.yd
|
12
|
-
# assert_equal 14, 1.stone
|
13
|
-
# end
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
# end
|
8
|
+
should "express non-base unit value in the base unit" do
|
9
|
+
assert_equal 3.feet, 1.yard
|
10
|
+
assert_equal 14.pounds, 1.stone
|
11
|
+
end
|
12
|
+
|
13
|
+
should "convert value from base unit to any other unit" do
|
14
|
+
assert_equal 16, 1.pound.in_ounces
|
15
|
+
end
|
24
16
|
end
|