Skip to content

Commit

Permalink
Added new units tn, LT, hyl, cwt, and cwt (US) in weight
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam091 committed Nov 3, 2023
1 parent c8fecb5 commit 6c961dd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/unit_measurements/unit_groups/weight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,22 @@
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"]
unit "LT", value: "2240 lb", aliases: ["imperial ton", "displacement ton", "imperial tons", "displacement tons", "long ton", "long tons", "weight ton", "weight tons"]

unit "drt", value: "60 gr", aliases: ["troy dram", "troy drams"]
unit "ozt", value: "480 gr", aliases: ["troy ounce", "troy ounces"]
unit "lbt", value: "5760 gr", aliases: ["troy pound", "troy pounds"]
unit "dwt", value: "1/20 ozt", aliases: ["pwt", "pennyweight", "pennyweights"]
unit "cwt", value: "112 lb", aliases: ["hundredweight", "long hundredweight", "imperial hundredweight"]
end

system :us_customary do
unit "tn", value: "2000 lb", aliases: ["ton", "tons", "short ton", "short tons"]
unit "cwt (US)", value: "100 lb", aliases: ["hundredweight (US)", "short hundredweight"]
end

system :gravitational_metric do
unit "hyl", value: "9.80665 kg", aliases: ["mug", "metric slug", "metric slugs", "hyls"]
end

system :foot_pound_second do
Expand Down
20 changes: 20 additions & 0 deletions spec/unit_measurements/unit_groups/weight_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@
expect(subject.convert_to("dr").quantity).to eq(2.82191695596643)
end

it "converts to tn" do
expect(subject.convert_to("tn").quantity).to eq(5.51155655462194e-6)
end

it "converts to LT" do
expect(subject.convert_to("LT").quantity).to eq(4.9210326380553e-6)
end

it "converts to ozt" do
expect(subject.convert_to("ozt").quantity).to eq(0.16075373284314)
end
Expand All @@ -68,8 +76,20 @@
expect(subject.convert_to("lbt").quantity).to eq(0.013396144403595)
end

it "converts to hyl" do
expect(subject.convert_to("hyl").quantity).to eq(0.000509858106488964)
end

it "converts to cwt" do
expect(subject.convert_to("cwt").quantity).to eq(0.0000984206527611061)
end

it "converts to slug" do
expect(subject.convert_to("slug").quantity).to eq(0.000342608829245948)
end

it "converts to cwt (US)" do
expect(subject.convert_to("cwt (US)").quantity).to eq(0.000110231131092439)
end
end
end

0 comments on commit 6c961dd

Please sign in to comment.