diff --git a/CHANGELOG.md b/CHANGELOG.md index 69a3cd7..15545de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [5.4.0](https://github.com/shivam091/unit_measurements/compare/v5.3.0...v5.4.0) - 2023-10-27 + +### What's new + +- Added new units `Å`, `lnk`, `lea`, `hh`, `nl`, and `sft` in length. +- Added new units `N`, `s`, `drt`, and `lbt` in weight. + +---------- + ## [5.3.0](https://github.com/shivam091/unit_measurements/compare/v5.2.0...v5.3.0) - 2023-10-24 ### What's new diff --git a/Gemfile.lock b/Gemfile.lock index 5323e4e..e6faa3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - unit_measurements (5.3.0) + unit_measurements (5.4.0) activesupport (~> 7.0) GEM diff --git a/lib/unit_measurements/unit_groups/length.rb b/lib/unit_measurements/unit_groups/length.rb index 624ec8b..68c268b 100644 --- a/lib/unit_measurements/unit_groups/length.rb +++ b/lib/unit_measurements/unit_groups/length.rb @@ -7,19 +7,31 @@ system :metric do si_unit "m", aliases: ["meter", "metre", "meters", "metres"] + + unit "Å", value: "1e-10 m", aliases: ["angstrom", "angstroms", "ångström"] end system :imperial do + unit "h", value: "4 in", aliases: ["hh", "hand", "hands"] + unit "in", value: "25.4 mm", aliases: ['"', "inch", "inches"] unit "ft", value: "12 in", aliases: ["'", "foot", "feet"] unit "yd", value: "3 ft", aliases: ["yard", "yards"] - unit "mi", value: "1760 yd", aliases: ["mile", "miles", "statute mile", "international mile"] + unit "mi", value: "5280 ft", aliases: ["mile", "miles", "statute mile", "international mile"] unit "ch", value: "22 yd", aliases: ["chain", "chains"] - unit "th", value: "1/1000 in", aliases: ["thou", "thousandth of an inch"] + unit "th", value: "1/1000 in", aliases: ["thou", "thousandth of an inch", "mil", "mils"] + unit "nl", value: "3 nmi", aliases: ["NL", "nleague", "nleagues", "nautical league", "nautical leagues"] + unit "ftm", value: "6 ft", aliases: ["fathom", "fathoms"] unit "fur", value: "220 yd", aliases: ["furlong", "furlongs"] unit "nmi", value: "1852 m", aliases: ["NMI", "M", "NM", "nautical mile", "nautical miles"] unit "rod", value: "16 1/2 ft", aliases: ["rods", "perch", "pole", "lug"] + unit "lnk", value: "33/50 ft", aliases: ["l", "li", "link", "links"] + unit "lea", value: "3 mi", aliases: ["league", "leagues"] + end + + system :us_customary do + unit "sft", value: "1200/3937 m", aliases: ["sfoot", "sfeet", "survey-foot", "survey-feet"] end system :astronomical do diff --git a/lib/unit_measurements/unit_groups/weight.rb b/lib/unit_measurements/unit_groups/weight.rb index 3662c19..af884cb 100644 --- a/lib/unit_measurements/unit_groups/weight.rb +++ b/lib/unit_measurements/unit_groups/weight.rb @@ -10,27 +10,28 @@ unit "q", value: "100 kg", aliases: ["quintal", "quintals"] unit "t", value: "1000 kg", aliases: ["tonne", "tonnes", "metric tonne", "metric tonnes"] + unit "N", value: "0.10197162129779283 kg", aliases: ["newton", "newtons"] + unit "ct", value: "200 mg", aliases: ["carat", "carats"] unit "Da", value: "1.660538921e-27 kg", aliases: ["dalton", "daltons"] end system :imperial do - unit "lb", value: [Rational(45_359_237, 1e+8), "kg"], aliases: ["lbs", "lbm", "pound-mass", "pound", "pounds", "#"] + unit "s", value: "20 gr", aliases: ["scruple", "scruples"] + + unit "lb", value: "0.45359237 kg", aliases: ["lbs", "lbm", "pound-mass", "pound", "pounds", "#"] unit "st", value: "14 lb", aliases: ["stone", "stones"] - unit "oz", value: [Rational(1, 16), "lb"], aliases: ["ounce", "ounces"] - end + unit "oz", value: "1/16 lb", aliases: ["ounce", "ounces"] + unit "dr", value: "1/16 oz", aliases: ["dram", "drams"] + unit "gr", value: "1/7000 lb", aliases: ["grain", "grains"] - system :troy_weight do - unit "gr", value: [Rational(1, 7000), "lb"], aliases: ["grain", "grains"] + unit "drt", value: "60 gr", aliases: ["troy dram", "troy drams"] unit "ozt", value: "480 gr", aliases: ["troy ounce", "troy ounces"] - unit "dwt", value: [Rational(1, 20), "ozt"], aliases: ["pennyweight", "pennyweights"] - end - - system :avoirdupois do - unit "dr", value: [Rational(1, 16), "oz"], aliases: ["dram", "drams"] + unit "lbt", value: "5760 gr", aliases: ["troy pound", "troy pounds"] + unit "dwt", value: "1/20 ozt", aliases: ["pwt", "pennyweight", "pennyweights"] end system :foot_pound_second do - unit "slug", value: "32.1740 lb", aliases: ["slugs"] + unit "slug", value: "32.17404856 lb", aliases: ["slugs"] end end diff --git a/lib/unit_measurements/version.rb b/lib/unit_measurements/version.rb index af0185f..c861720 100644 --- a/lib/unit_measurements/version.rb +++ b/lib/unit_measurements/version.rb @@ -4,5 +4,5 @@ module UnitMeasurements # Current stable version. - VERSION = "5.3.0" + VERSION = "5.4.0" end diff --git a/spec/unit_measurements/unit_groups/length_spec.rb b/spec/unit_measurements/unit_groups/length_spec.rb index 63f882c..9e10c2a 100644 --- a/spec/unit_measurements/unit_groups/length_spec.rb +++ b/spec/unit_measurements/unit_groups/length_spec.rb @@ -55,6 +55,30 @@ it "converts to rod" do expect(subject.convert_to("rod").quantity).to eq(0.198838781515947) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(1e+10) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(4.97096953789867) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(0.000207123730745778) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(9.84251968503937) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(0.000179985601151908) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(3.28083333333333) + end end describe "in" do @@ -107,6 +131,30 @@ it "converts to rod" do expect(subject.convert_to("rod").quantity).to eq(0.00505050505050505) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(2.54e+8) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(0.126262626262626) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(5.26094276094276e-6) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(0.25) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(4.57163426925846e-6) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(0.0833331666666667) + end end describe "ft" do @@ -159,6 +207,30 @@ it "converts to rod" do expect(subject.convert_to("rod").quantity).to eq(0.0606060606060606) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(3048000000) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(1.51515151515152) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(6.31313131313131e-5) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(3) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(5.48596112311015e-5) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(0.999998) + end end describe "yd" do @@ -211,6 +283,30 @@ it "converts to rod" do expect(subject.convert_to("rod").quantity).to eq(0.181818181818182) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(9.144e+9) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(4.54545454545454) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(0.000189393939393939) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(9) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(0.000164578833693305) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(2.999994) + end end describe "mi" do @@ -263,6 +359,30 @@ it "converts to rod" do expect(subject.convert_to("rod").quantity).to eq(320) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(1.609344e+13) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(8000) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(0.333333333333333) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(15840) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(0.289658747300216) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(5279.98944) + end end describe "ch" do @@ -315,6 +435,30 @@ it "converts to rod" do expect(subject.convert_to("rod").quantity).to eq(4) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(2.01168e+11) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(100) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(0.00416666666666667) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(198) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(0.0036207343412527) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(65.999868) + end end describe "th" do @@ -367,6 +511,30 @@ it "converts to rod" do expect(subject.convert_to("rod").quantity).to eq(5.05050505050505e-6) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(254000) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(0.000126262626262626) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(5.26094276094276e-9) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(0.00025) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(4.57163426925846e-9) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(8.33331666666667e-5) + end end describe "au" do @@ -419,6 +587,30 @@ it "converts to rod" do expect(subject.convert_to("rod").quantity).to eq(2.97458583273682e+10) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(1.495978707e+21) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(7.43646458184204e+11) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(3.09852690910085e+7) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(1.47241998720472e+12) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(2.69254626889849e+7) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(4.9080568078825e+11) + end end describe "pc" do @@ -471,6 +663,30 @@ it "converts to rod" do expect(subject.convert_to("rod").quantity).to eq(6.13552370454817e+15) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(3.08567758149137e+26) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(1.53388092613704e+17) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(6.39117052557101e+12) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(3.03708423375135e+17) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(5.55377534465689e+12) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(1.01235938652763e+17) + end end describe "ftm" do @@ -523,6 +739,30 @@ it "converts to rod" do expect(subject.convert_to("rod").quantity).to eq(0.363636363636364) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(1.8288e+10) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(9.09090909090909) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(0.000378787878787879) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(18) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(0.000329157667386609) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(5.999988) + end end describe "fur" do @@ -575,6 +815,30 @@ it "converts to rod" do expect(subject.convert_to("rod").quantity).to eq(40) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(2.011680000000e+12) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(1000) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(0.0416666666666667) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(1980) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(0.036207343412527) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(659.99868) + end end describe "nmi" do @@ -627,6 +891,30 @@ it "converts to rod" do expect(subject.convert_to("rod").quantity).to eq(368.249423367534) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(1.852e+13) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(9206.23558418834) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(0.383593149341181) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(18228.3464566929) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(0.333333333333333) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(6076.10333333333) + end end describe "rod" do @@ -679,5 +967,485 @@ it "converts to nmi" do expect(subject.convert_to("nmi").quantity).to eq(0.00271555075593952) end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(5.0292e+10) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(25) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(0.00104166666666667) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(49.5) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(0.000905183585313175) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(16.499967) + end + end + + describe "Å" do + subject { described_class.new(1, "Å") } + + it "converts to m" do + expect(subject.convert_to("m").quantity).to eq(1e-10) + end + + it "converts to in" do + expect(subject.convert_to("in").quantity).to eq(3.93700787401575e-9) + end + + it "converts to ft" do + expect(subject.convert_to("ft").quantity).to eq(3.28083989501312e-10) + end + + it "converts to yd" do + expect(subject.convert_to("yd").quantity).to eq(1.09361329833771e-10) + end + + it "converts to mi" do + expect(subject.convert_to("mi").quantity).to eq(6.21371192237334e-14) + end + + it "converts to ch" do + expect(subject.convert_to("ch").quantity).to eq(4.97096953789867e-12) + end + + it "converts to th" do + expect(subject.convert_to("th").quantity).to eq(3.93700787401575e-6) + end + + it "converts to au" do + expect(subject.convert_to("au").quantity).to eq(6.68458712226845e-22) + end + + it "converts to pc" do + expect(subject.convert_to("pc").quantity).to eq(3.24077928944437e-27) + end + + it "converts to ftm" do + expect(subject.convert_to("ftm").quantity).to eq(5.46806649168854e-11) + end + + it "converts to fur" do + expect(subject.convert_to("fur").quantity).to eq(4.97096953789867e-13) + end + + it "converts to nmi" do + expect(subject.convert_to("nmi").quantity).to eq(5.39956803455724e-14) + end + + it "converts to rod" do + expect(subject.convert_to("rod").quantity).to eq(1.98838781515947e-11) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(4.97096953789867e-10) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(2.07123730745778e-14) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(9.84251968503937e-10) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(1.79985601151908e-14) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(3.28083333333333e-10) + end + end + + describe "lnk" do + subject { described_class.new(1, "lnk") } + + it "converts to m" do + expect(subject.convert_to("m").quantity).to eq(0.201168) + end + + it "converts to in" do + expect(subject.convert_to("in").quantity).to eq(7.92) + end + + it "converts to ft" do + expect(subject.convert_to("ft").quantity).to eq(0.66) + end + + it "converts to yd" do + expect(subject.convert_to("yd").quantity).to eq(0.22) + end + + it "converts to mi" do + expect(subject.convert_to("mi").quantity).to eq(0.000125) + end + + it "converts to ch" do + expect(subject.convert_to("ch").quantity).to eq(0.01) + end + + it "converts to th" do + expect(subject.convert_to("th").quantity).to eq(7920) + end + + it "converts to au" do + expect(subject.convert_to("au").quantity).to eq(1.3447250222125e-12) + end + + it "converts to pc" do + expect(subject.convert_to("pc").quantity).to eq(6.51941088098944e-18) + end + + it "converts to ftm" do + expect(subject.convert_to("ftm").quantity).to eq(0.11) + end + + it "converts to fur" do + expect(subject.convert_to("fur").quantity).to eq(0.001) + end + + it "converts to nmi" do + expect(subject.convert_to("nmi").quantity).to eq(0.000108622030237581) + end + + it "converts to rod" do + expect(subject.convert_to("rod").quantity).to eq(0.04) + end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(2.01168e+9) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(4.16666666666667e-5) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(1.98) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(3.6207343412527e-5) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(0.65999868) + end + end + + describe "lea" do + subject { described_class.new(1, "lea") } + + it "converts to m" do + expect(subject.convert_to("m").quantity).to eq(4828.032) + end + + it "converts to in" do + expect(subject.convert_to("in").quantity).to eq(1.9008e+5) + end + + it "converts to ft" do + expect(subject.convert_to("ft").quantity).to eq(15840) + end + + it "converts to yd" do + expect(subject.convert_to("yd").quantity).to eq(5280) + end + + it "converts to mi" do + expect(subject.convert_to("mi").quantity).to eq(3) + end + + it "converts to ch" do + expect(subject.convert_to("ch").quantity).to eq(240) + end + + it "converts to th" do + expect(subject.convert_to("th").quantity).to eq(1.9008e+8) + end + + it "converts to au" do + expect(subject.convert_to("au").quantity).to eq(3.22734005331e-8) + end + + it "converts to pc" do + expect(subject.convert_to("pc").quantity).to eq(1.56465861143747e-13) + end + + it "converts to ftm" do + expect(subject.convert_to("ftm").quantity).to eq(2640) + end + + it "converts to fur" do + expect(subject.convert_to("fur").quantity).to eq(24) + end + + it "converts to nmi" do + expect(subject.convert_to("nmi").quantity).to eq(2.60692872570194) + end + + it "converts to rod" do + expect(subject.convert_to("rod").quantity).to eq(960) + end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(4.828032e+13) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(24000) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(47520) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(0.868976241900648) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(15839.96832) + end + end + + describe "h" do + subject { described_class.new(1, "hh") } + + it "converts to m" do + expect(subject.convert_to("m").quantity).to eq(0.1016) + end + + it "converts to in" do + expect(subject.convert_to("in").quantity).to eq(4) + end + + it "converts to ft" do + expect(subject.convert_to("ft").quantity).to eq(0.333333333333333) + end + + it "converts to yd" do + expect(subject.convert_to("yd").quantity).to eq(0.111111111111111) + end + + it "converts to mi" do + expect(subject.convert_to("mi").quantity).to eq(6.31313131313131e-5) + end + + it "converts to ch" do + expect(subject.convert_to("ch").quantity).to eq(0.00505050505050505) + end + + it "converts to th" do + expect(subject.convert_to("th").quantity).to eq(4000) + end + + it "converts to au" do + expect(subject.convert_to("au").quantity).to eq(6.79154051622474e-13) + end + + it "converts to pc" do + expect(subject.convert_to("pc").quantity).to eq(3.29263175807547e-18) + end + + it "converts to ftm" do + expect(subject.convert_to("ftm").quantity).to eq(0.0555555555555556) + end + + it "converts to fur" do + expect(subject.convert_to("fur").quantity).to eq(0.000505050505050505) + end + + it "converts to nmi" do + expect(subject.convert_to("nmi").quantity).to eq(5.48596112311015e-5) + end + + it "converts to rod" do + expect(subject.convert_to("rod").quantity).to eq(0.0202020202020202) + end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(1.016e+9) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(0.505050505050505) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(2.1043771043771e-5) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(1.82865370770338e-5) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(0.333332666666667) + end + end + + describe "nl" do + subject { described_class.new(1, "nl") } + + it "converts to m" do + expect(subject.convert_to("m").quantity).to eq(5556) + end + + it "converts to in" do + expect(subject.convert_to("in").quantity).to eq(2.18740157480315e+5) + end + + it "converts to ft" do + expect(subject.convert_to("ft").quantity).to eq(18228.3464566929) + end + + it "converts to yd" do + expect(subject.convert_to("yd").quantity).to eq(6076.11548556431) + end + + it "converts to mi" do + expect(subject.convert_to("mi").quantity).to eq(3.45233834407063) + end + + it "converts to ch" do + expect(subject.convert_to("ch").quantity).to eq(276.18706752565) + end + + it "converts to th" do + expect(subject.convert_to("th").quantity).to eq(2.18740157480315e+8) + end + + it "converts to au" do + expect(subject.convert_to("au").quantity).to eq(3.71395660513235e-8) + end + + it "converts to pc" do + expect(subject.convert_to("pc").quantity).to eq(1.80057697321529e-13) + end + + it "converts to ftm" do + expect(subject.convert_to("ftm").quantity).to eq(3038.05774278215) + end + + it "converts to fur" do + expect(subject.convert_to("fur").quantity).to eq(27.618706752565) + end + + it "converts to nmi" do + expect(subject.convert_to("nmi").quantity).to eq(3) + end + + it "converts to rod" do + expect(subject.convert_to("rod").quantity).to eq(1104.7482701026) + end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(5.556e+13) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(27618.706752565) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(1.15077944802354) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(54685.0393700787) + end + + it "converts to sft" do + expect(subject.convert_to("sft").quantity).to eq(18228.31) + end + end + + describe "sft" do + subject { described_class.new(1, "sft") } + + it "converts to m" do + expect(subject.convert_to("m").quantity).to eq(0.304800609601219) + end + + it "converts to in" do + expect(subject.convert_to("in").quantity).to eq(12.000024000048) + end + + it "converts to ft" do + expect(subject.convert_to("ft").quantity).to eq(1.000002000004) + end + + it "converts to yd" do + expect(subject.convert_to("yd").quantity).to eq(0.333334000001333) + end + + it "converts to mi" do + expect(subject.convert_to("mi").quantity).to eq(0.000189394318182576) + end + + it "converts to ch" do + expect(subject.convert_to("ch").quantity).to eq(0.0151515454546061) + end + + it "converts to th" do + expect(subject.convert_to("th").quantity).to eq(12000.024000048) + end + + it "converts to au" do + expect(subject.convert_to("au").quantity).to eq(2.03746622979988e-12) + end + + it "converts to pc" do + expect(subject.convert_to("pc").quantity).to eq(9.87791503005648e-18) + end + + it "converts to ftm" do + expect(subject.convert_to("ftm").quantity).to eq(0.166667000000667) + end + + it "converts to fur" do + expect(subject.convert_to("fur").quantity).to eq(0.00151515454546061) + end + + it "converts to nmi" do + expect(subject.convert_to("nmi").quantity).to eq(0.00016457916285163) + end + + it "converts to rod" do + expect(subject.convert_to("rod").quantity).to eq(0.0606061818184242) + end + + it "converts to Å" do + expect(subject.convert_to("Å").quantity).to eq(3.04800609601219e+9) + end + + it "converts to lnk" do + expect(subject.convert_to("lnk").quantity).to eq(1.51515454546061) + end + + it "converts to lea" do + expect(subject.convert_to("lea").quantity).to eq(6.31314393941919e-5) + end + + it "converts to hh" do + expect(subject.convert_to("h").quantity).to eq(3.000006000012) + end + + it "converts to nl" do + expect(subject.convert_to("nl").quantity).to eq(5.48597209505434e-5) + end end end diff --git a/spec/unit_measurements/unit_groups/weight_spec.rb b/spec/unit_measurements/unit_groups/weight_spec.rb index 7c5e3c9..b736119 100644 --- a/spec/unit_measurements/unit_groups/weight_spec.rb +++ b/spec/unit_measurements/unit_groups/weight_spec.rb @@ -53,7 +53,23 @@ end it "converts to slug" do - expect(subject.convert_to("slug").quantity).to eq(0.000137043738537252) + expect(subject.convert_to("slug").quantity).to eq(0.000137043531698379) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(0.0196133) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(1.54323583529414) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(0.514411945098048) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(0.005358457761438) end end @@ -105,7 +121,23 @@ end it "converts to slug" do - expect(subject.convert_to("slug").quantity).to eq(13.7043738537252) + expect(subject.convert_to("slug").quantity).to eq(13.7043531698379) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(1961.33) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(1.54323583529414e+5) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(51441.1945098048) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(535.8457761438) end end @@ -157,7 +189,23 @@ end it "converts to slug" do - expect(subject.convert_to("slug").quantity).to eq(137.043738537252) + expect(subject.convert_to("slug").quantity).to eq(137.043531698379) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(19613.3) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(1.54323583529414e+6) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(5.14411945098048e+5) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(5358.457761438) end end @@ -209,7 +257,23 @@ end it "converts to slug" do - expect(subject.convert_to("slug").quantity).to eq(2.74087477074504e-5) + expect(subject.convert_to("slug").quantity).to eq(2.74087063396758e-05) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(0.00392266) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(0.308647167058829) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(0.10288238901961) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(0.0010716915522876) end end @@ -261,7 +325,23 @@ end it "converts to slug" do - expect(subject.convert_to("slug").quantity).to eq(2.27566461720455e-28) + expect(subject.convert_to("slug").quantity).to eq(2.27566118256456e-28) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(3.25686480192493e-26) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(2.56260316878787e-24) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(8.54201056262623e-25) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(8.89792766940233e-27) end end @@ -313,7 +393,23 @@ end it "converts to slug" do - expect(subject.convert_to("slug").quantity).to eq(8.88028487953894e-6) + expect(subject.convert_to("slug").quantity).to eq(8.88027147660542e-06) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(0.001270920461503) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(0.1) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(0.0333333333333333) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(0.000347222222222222) end end @@ -365,7 +461,23 @@ end it "converts to slug" do - expect(subject.convert_to("slug").quantity).to eq(0.0621619941567726) + expect(subject.convert_to("slug").quantity).to eq(0.0621619003362379) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(8.896443230521) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(700) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(233.333333333333) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(2.43055555555556) end end @@ -417,7 +529,23 @@ end it "converts to slug" do - expect(subject.convert_to("slug").quantity).to eq(0.00388512463479828) + expect(subject.convert_to("slug").quantity).to eq(0.00388511877101487) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(0.556027701907562) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(43.75) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(14.5833333333333) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(0.151909722222222) end end @@ -469,7 +597,23 @@ end it "converts to slug" do - expect(subject.convert_to("slug").quantity).to eq(0.870267918194816) + expect(subject.convert_to("slug").quantity).to eq(0.870266604707331) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(124.550205227294) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(9800) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(3266.66666666667) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(34.0277777777778) end end @@ -521,7 +665,23 @@ end it "converts to slug" do - expect(subject.convert_to("slug").quantity).to eq(0.000242820289674893) + expect(subject.convert_to("slug").quantity).to eq(0.000242819923188429) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(0.0347517313692227) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(2.734375) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(0.911458333333333) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(0.00949435763888889) end end @@ -573,7 +733,23 @@ end it "converts to slug" do - expect(subject.convert_to("slug").quantity).to eq(0.00426253674217869) + expect(subject.convert_to("slug").quantity).to eq(0.0042625303087706) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(0.61004182152144) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(48) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(16) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(0.166666666666667) end end @@ -625,7 +801,23 @@ end it "converts to slug" do - expect(subject.convert_to("slug").quantity).to eq(0.000213126837108934) + expect(subject.convert_to("slug").quantity).to eq(0.00021312651543853) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(0.030502091076072) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(2.4) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(0.8) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(0.00833333333333333) end end @@ -633,51 +825,339 @@ subject { described_class.new(2, "slug") } it "converts to g" do - expect(subject.convert_to("g").quantity).to eq(29187.76182476) + expect(subject.convert_to("g").quantity).to eq(29187.805877651) + end + + it "converts to q" do + expect(subject.convert_to("q").quantity).to eq(0.29187805877651) + end + + it "converts to t" do + expect(subject.convert_to("t").quantity).to eq(0.029187805877651) + end + + it "converts to st" do + expect(subject.convert_to("st").quantity).to eq(4.59629265142857) + end + + it "converts to oz" do + expect(subject.convert_to("oz").quantity).to eq(1029.56955392) + end + + it "converts to ct" do + expect(subject.convert_to("ct").quantity).to eq(1.45939029388255e+5) + end + + it "converts to dr" do + expect(subject.convert_to("dr").quantity).to eq(16473.11286272) + end + + it "converts to Da" do + expect(subject.convert_to("Da").quantity).to eq(1.75773090943714e+28) + end + + it "converts to lb" do + expect(subject.convert_to("lb").quantity).to eq(64.34809712) + end + + it "converts to gr" do + expect(subject.convert_to("gr").quantity).to eq(4.5043667984e+5) + end + + it "converts to dwt" do + expect(subject.convert_to("dwt").quantity).to eq(18768.1949933333) + end + + it "converts to ozt" do + expect(subject.convert_to("ozt").quantity).to eq(938.409749666667) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(286.234596510066) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(22521.833992) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(7507.27799733333) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(78.2008124722222) + end + end + + describe "N" do + subject { described_class.new(2, "N") } + + it "converts to g" do + expect(subject.convert_to("g").quantity).to eq(203.943242595586) + end + + it "converts to q" do + expect(subject.convert_to("q").quantity).to eq(0.00203943242595586) + end + + it "converts to t" do + expect(subject.convert_to("t").quantity).to eq(0.000203943242595586) + end + + it "converts to st" do + expect(subject.convert_to("st").quantity).to eq(0.0321155632999586) + end + + it "converts to oz" do + expect(subject.convert_to("oz").quantity).to eq(7.19388617919074) + end + + it "converts to ct" do + expect(subject.convert_to("ct").quantity).to eq(1019.71621297793) + end + + it "converts to dr" do + expect(subject.convert_to("dr").quantity).to eq(115.102178867052) + end + + it "converts to Da" do + expect(subject.convert_to("Da").quantity).to eq(1.22817502207517e+26) + end + + it "converts to lb" do + expect(subject.convert_to("lb").quantity).to eq(0.449617886199421) + end + + it "converts to gr" do + expect(subject.convert_to("gr").quantity).to eq(3147.32520339595) + end + + it "converts to dwt" do + expect(subject.convert_to("dwt").quantity).to eq(131.138550141498) + end + + it "converts to ozt" do + expect(subject.convert_to("ozt").quantity).to eq(6.55692750707489) + end + + it "converts to slug" do + expect(subject.convert_to("slug").quantity).to eq(0.0139745511156592) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(157.366260169797) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(52.4554200565991) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(0.546410625589574) + end + end + + describe "s" do + subject { described_class.new(2, "s") } + + it "converts to g" do + expect(subject.convert_to("g").quantity).to eq(2.5919564) + end + + it "converts to q" do + expect(subject.convert_to("q").quantity).to eq(2.5919564e-5) + end + + it "converts to t" do + expect(subject.convert_to("t").quantity).to eq(2.5919564e-6) + end + + it "converts to st" do + expect(subject.convert_to("st").quantity).to eq(0.000408163265306122) + end + + it "converts to oz" do + expect(subject.convert_to("oz").quantity).to eq(0.0914285714285714) + end + + it "converts to ct" do + expect(subject.convert_to("ct").quantity).to eq(12.959782) + end + + it "converts to dr" do + expect(subject.convert_to("dr").quantity).to eq(1.46285714285714) + end + + it "converts to Da" do + expect(subject.convert_to("Da").quantity).to eq(1.56091276586223e+24) + end + + it "converts to lb" do + expect(subject.convert_to("lb").quantity).to eq(0.00571428571428571) + end + + it "converts to gr" do + expect(subject.convert_to("gr").quantity).to eq(40) + end + + it "converts to dwt" do + expect(subject.convert_to("dwt").quantity).to eq(1.66666666666667) + end + + it "converts to ozt" do + expect(subject.convert_to("ozt").quantity).to eq(0.0833333333333333) + end + + it "converts to slug" do + expect(subject.convert_to("slug").quantity).to eq(0.000177605429532108) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(0.02541840923006) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(0.666666666666667) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(0.00694444444444444) + end + end + + describe "drt" do + subject { described_class.new(2, "drt") } + + it "converts to g" do + expect(subject.convert_to("g").quantity).to eq(7.7758692) end it "converts to q" do - expect(subject.convert_to("q").quantity).to eq(0.2918776182476) + expect(subject.convert_to("q").quantity).to eq(7.7758692e-5) end it "converts to t" do - expect(subject.convert_to("t").quantity).to eq(0.02918776182476) + expect(subject.convert_to("t").quantity).to eq(7.7758692e-6) end it "converts to st" do - expect(subject.convert_to("st").quantity).to eq(4.59628571428571) + expect(subject.convert_to("st").quantity).to eq(0.00122448979591837) end it "converts to oz" do - expect(subject.convert_to("oz").quantity).to eq(1029.568) + expect(subject.convert_to("oz").quantity).to eq(0.274285714285714) end it "converts to ct" do - expect(subject.convert_to("ct").quantity).to eq(1.459388091238e+5) + expect(subject.convert_to("ct").quantity).to eq(38.879346) end it "converts to dr" do - expect(subject.convert_to("dr").quantity).to eq(1.6473088e+4) + expect(subject.convert_to("dr").quantity).to eq(4.38857142857143) end it "converts to Da" do - expect(subject.convert_to("Da").quantity).to eq(1.7577282565098e+28) + expect(subject.convert_to("Da").quantity).to eq(4.6827382975867e+24) end it "converts to lb" do - expect(subject.convert_to("lb").quantity).to eq(64.348) + expect(subject.convert_to("lb").quantity).to eq(0.0171428571428571) end it "converts to gr" do - expect(subject.convert_to("gr").quantity).to eq(4.50436e+5) + expect(subject.convert_to("gr").quantity).to eq(120) end it "converts to dwt" do - expect(subject.convert_to("dwt").quantity).to eq(18768.1666666667) + expect(subject.convert_to("dwt").quantity).to eq(5) end it "converts to ozt" do - expect(subject.convert_to("ozt").quantity).to eq(938.408333333333) + expect(subject.convert_to("ozt").quantity).to eq(0.25) + end + + it "converts to slug" do + expect(subject.convert_to("slug").quantity).to eq(0.000532816288596325) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(0.07625522769018) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(6) + end + + it "converts to lbt" do + expect(subject.convert_to("lbt").quantity).to eq(0.0208333333333333) + end + end + + describe "lbt" do + subject { described_class.new(2, "lbt") } + + it "converts to g" do + expect(subject.convert_to("g").quantity).to eq(746.4834432) + end + + it "converts to q" do + expect(subject.convert_to("q").quantity).to eq(0.007464834432) + end + + it "converts to t" do + expect(subject.convert_to("t").quantity).to eq(0.0007464834432) + end + + it "converts to st" do + expect(subject.convert_to("st").quantity).to eq(0.117551020408163) + end + + it "converts to oz" do + expect(subject.convert_to("oz").quantity).to eq(26.3314285714286) + end + + it "converts to ct" do + expect(subject.convert_to("ct").quantity).to eq(3732.417216) + end + + it "converts to dr" do + expect(subject.convert_to("dr").quantity).to eq(421.302857142857) + end + + it "converts to Da" do + expect(subject.convert_to("Da").quantity).to eq(4.49542876568323e+26) + end + + it "converts to lb" do + expect(subject.convert_to("lb").quantity).to eq(1.64571428571429) + end + + it "converts to gr" do + expect(subject.convert_to("gr").quantity).to eq(11520) + end + + it "converts to dwt" do + expect(subject.convert_to("dwt").quantity).to eq(480) + end + + it "converts to ozt" do + expect(subject.convert_to("ozt").quantity).to eq(24) + end + + it "converts to slug" do + expect(subject.convert_to("slug").quantity).to eq(0.0511503637052472) + end + + it "converts to N" do + expect(subject.convert_to("N").quantity).to eq(7.32050185825728) + end + + it "converts to s" do + expect(subject.convert_to("s").quantity).to eq(576) + end + + it "converts to drt" do + expect(subject.convert_to("drt").quantity).to eq(192) end end end diff --git a/units.md b/units.md index 1e6a715..7251a1c 100644 --- a/units.md +++ b/units.md @@ -9,27 +9,33 @@ check below list of bundled units before converting your measurements. in addition to [Decimal SI prefixes](README.md#decimal-si-prefixes). 3. Primitive unit of the unit group is in _emphasised typeface_. -## 1. Length/Distance +## 1. Length or distance These units are defined in `UnitMeasurements::Length`. | # | Name | Aliases | |:--|:--|:--| | _1_ | _m*_ | _meter, metre, meters, metres_ | -| 2 | in | ", inch, inches | -| 3 | ft | ', foot, feet | -| 4 | yd | yard, yards | -| 5 | mi | mile, miles, statute mile, international mile | -| 6 | ch | chain, chains | -| 7 | th | thou, thousandth of an inch | -| 8 | au | astronomical unit, astronomical units | -| 9 | pc | parsec, parsecs | -| 10 | ftm | fathom, fathoms | -| 11 | fur | furlong, furlongs | -| 12 | nmi | NMI, M, NM, nautical mile, nautical miles | -| 13 | rod | rods, perch, pole, lug | - -## 2. Weight/Mass +| 2 | Å | angstrom, angstroms, ångström | +| 3 | h | hh, hand, hands | +| 4 | in | ", inch, inches | +| 5 | ft | ', foot, feet | +| 6 | yd | yard, yards | +| 7 | mi | mile, miles, statute mile, international mile | +| 8 | ch | chain, chains | +| 9 | th | thou, thousandth of an inch, mil, mils | +| 10 | au | astronomical unit, astronomical units | +| 11 | pc | parsec, parsecs | +| 12 | nl | NL, nleague, nleagues, nautical league, nautical leagues | +| 13 | ftm | fm, fathom, fathoms | +| 14 | fur | furlong, furlongs | +| 15 | nmi | NMI, M, NM, nautical mile, nautical miles | +| 16 | rod | rods, perch, pole, lug | +| 17 | lnk | l, li, link, links | +| 18 | lea | league, leagues | +| 19 | sft | sfoot, sfeet, survey-foot, survey-feet | + +## 2. Weight or mass These units are defined in `UnitMeasurements::Weight`. @@ -38,16 +44,20 @@ These units are defined in `UnitMeasurements::Weight`. | _1_ | _g*_ | _gram, grams, gramme, grammes_ | | 2 | q | quintal, quintals | | 3 | t | tonne, tonnes, metric tonne, metric tonnes | -| 4 | ct | carat, carats | -| 5 | Da | dalton, daltons | -| 6 | st | stone, stones | -| 7 | dr | dram, drams | -| 8 | dwt | pennyweight, pennyweights | -| 9 | ozt | troy ounce, troy ounces | -| 10 | slug | slugs | -| 11 | lb | lbs, lbm, pound-mass, pound, pounds, \# | -| 12 | oz | ounce, ounces | -| 13 | gr | grain, grains | +| 4 | N | newton, newtons | +| 5 | s | scruple, scruples | +| 6 | ct | carat, carats | +| 7 | Da | dalton, daltons | +| 8 | st | stone, stones | +| 9 | dr | dram, drams | +| 10 | lb | lbs, lbm, pound-mass, pound, pounds, \# | +| 11 | oz | ounce, ounces | +| 12 | gr | grain, grains | +| 13 | dwt | pennyweight, pennyweights | +| 14 | ozt | troy ounce, troy ounces | +| 15 | lbt | troy pound, troy pounds | +| 16 | drt | troy dram, troy drams | +| 17 | slug | slugs | ## 3. Time