Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

extend alchemist for pF-value

  • Loading branch information...
commit 67560e6a3a884ab83b656ce1481ec394aa983cbf 1 parent b2b22df
@andreasmueller authored
View
3  lib/alchemist.rb
@@ -284,7 +284,8 @@ class << self
:poundal_per_square_foot => 1.488164, :poundals_per_square_foot => 1.488164,
:pound_force_per_square_foot => 47.88026,
:pound_force_per_square_inch => 6.894757e+3, :psi => 6.894757e+3,
- :torr => 1.333224e+2, :torrs => 1.333224e+2
+ :torr => 1.333224e+2, :torrs => 1.333224e+2,
+ :pf_value => [Proc.new{ |pf| 100.0*10**pf}, Proc.new{ |pf| Math.log10(pf/100.0)}]
},
:radioactivity => {
:becquerel => 1.0, :becquerels => 1.0, :Bq => 1.0,
View
5 locales/de.yml
@@ -87,6 +87,11 @@ de:
one: "Pascal"
many: "Pascal"
symbol: "Pa"
+ pf_value:
+ name:
+ one: "pF-Wert"
+ many: "pF-Wert"
+ symbol: "pF"
distance:
meter:
name:
View
5 locales/en.yml
@@ -87,6 +87,11 @@ en:
one: "pascal"
many: "pascals"
symbol: "Pa"
+ pf_value:
+ name:
+ one: "pF-value"
+ many: "pF-value"
+ symbol: "pF"
distance:
meter:
name:
View
16 test/alchemist_test.rb
@@ -76,7 +76,7 @@ def test_division
def test_temperature
assert_equal(1.fahrenheit, 1.fahrenheit)
- assert_in_delta(1.fahrenheit, 1.fahrenheit.to.celsius.to.fahrenheit, 1e-5.fahrenheit)
+ assert_in_delta(1.fahrenheit, 1.fahrenheit.to.celsius.to.fahrenheit, 1e-5)
end
def test_density
@@ -185,5 +185,19 @@ def test_dimensionless_units
assert 1000.unitless.to.decibel.to_s == "30.0 dB"
end
+ def test_pf_value
+ assert 1000.pascal.to.pf_value.to_f == 1
+ assert 3.pf_value.to.pascal.to_f == 100000
+ assert_in_delta(2.123.pf_value, 2.123.pf_value.to.pascal.to.pf_value, 1e-10)
+
+ I18n.locale = "en"
+ assert 1.pf_value.unit_name_t.to_s == "pF-value"
+ assert 1.pf_value.unit_symbol_t == "pF"
+
+ I18n.locale = "de"
+ assert 1.pf_value.unit_name_t.to_s == "pF-Wert"
+ assert 1.pf_value.unit_symbol_t == "pF"
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.