Skip to content

Commit

Permalink
extend alchemist for particulate matter concentration
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasmueller committed Sep 11, 2013
1 parent b5d8604 commit d18385f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/alchemist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class << self
@@si_units += %w[ampere]
@@si_units += %w[metre_per_second metre_per_second_squared]
@@si_units += %w[unitless]
@@si_units += %w[pieces_per_cubic_metre]

@@common_metric_units = {
:dimensionless => :unitless,
Expand All @@ -38,7 +39,8 @@ class << self
:pressure => :pascal,
:distance => :meter,
:velocity => :metre_per_second,
:acceleration => :metre_per_second_squared
:acceleration => :metre_per_second_squared,
:particulate_matter_concentration => :pieces_per_cubic_metre
}
@@common_imperial_units = {
:dimensionless => :unitless,
Expand All @@ -53,7 +55,8 @@ class << self
:pressure => :psi,
:distance => :feet,
:velocity => :metre_per_second,
:acceleration => :metre_per_second_squared
:acceleration => :metre_per_second_squared,
:particulate_matter_concentration => :pieces_per_cubic_foot
}

@@operator_actions = {}
Expand Down Expand Up @@ -265,6 +268,10 @@ class << self
#unusual measurements
:elephant => 5443108.44, :elephants => 5443108.44
},
:particulate_matter_concentration => {
:pieces_per_cubic_metre => 1.0,
:pieces_per_cubic_foot => 35.314667
},
:power => {
:watt => 1.0, :watts => 1.0, :W => 1.0,
:british_thermal_unit_per_hour => 2.928751e-1, :british_thermal_units_per_hour => 2.928751e-1,
Expand Down
11 changes: 11 additions & 0 deletions locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,14 @@ de:
one: "Umdrehung pro Minute"
many: "Umdrehungen pro Minute"
symbol: "RPM"
particulate_matter_concentration:
pieces_per_cubic_metre:
name:
one: "Partikel pro Kubikmeter"
many: "Partikel pro Kubikmeter"
symbol: "part./m³"
pieces_per_cubic_foot:
name:
one: "Partikel pro Kubikfuss"
many: "Partikel pro Kubikfuss"
symbol: "part./cft"
11 changes: 11 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,14 @@ en:
one: "Revolution per minute"
many: "Revolutions per minute"
symbol: "RPM"
particulate_matter_concentration:
pieces_per_cubic_metre:
name:
one: "piece per cubic metre"
many: "pieces per cubic metre"
symbol: "pcs/m³"
pieces_per_cubic_foot:
name:
one: "piece per cubic foot"
many: "pieces per cubic foot"
symbol: "pcs/cft"
13 changes: 13 additions & 0 deletions test/alchemist_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,18 @@ def test_standard_gravity
assert 1.standard_gravity.unit_symbol_t.to_s == "g"
end

def test_particulate_matter_concentration
assert_in_delta(1.pieces_per_cubic_metre.to.pieces_per_cubic_foot.to_f, 0.0283168, 1e-5)
assert_in_delta(1.pieces_per_cubic_foot.to.pieces_per_cubic_metre.to_f, 35.3146667, 1e-5)
I18n.locale = "en"
assert 1.pieces_per_cubic_metre.unit_name_t.to_s == "piece per cubic metre"
assert 2.pieces_per_cubic_metre.unit_name_t.to_s == "pieces per cubic metre"
assert 1.pieces_per_cubic_metre.unit_symbol_t.to_s == "pcs/m³"
I18n.locale = "de"
assert 1.pieces_per_cubic_metre.unit_name_t.to_s == "Partikel pro Kubikmeter"
assert 2.pieces_per_cubic_metre.unit_name_t.to_s == "Partikel pro Kubikmeter"
assert 1.pieces_per_cubic_metre.unit_symbol_t.to_s == "part./m³"
end

end

0 comments on commit d18385f

Please sign in to comment.