Module: Alchemist::ConversionTable

Defined in:
lib/alchemist/conversion_table.rb

Class Method Summary collapse

Class Method Details

.defaultObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/alchemist/conversion_table.rb', line 3

def self.default
  {
    :absorbed_radiation_dose => {
      :gray => 1.0, :grays => 1.0, :Gy => 1.0,
      :rad => 1.0e-2, :rads => 1.0e-2
    },
    :angles => {
      :radian => 1.0, :radians => 1.0,
      :degree => Math::PI / 180.0, :degrees => Math::PI / 180.0,
      :arcminute => Math::PI / 10800.0, :arcminutes => Math::PI / 10800.0,
      :arcsecond => Math::PI / 648000.0, :arcseconds => Math::PI / 648000.0,
      :mil => 9.817477e-4, :mils => 9.817477e-4,
      :revolution => Math::PI * 2.0, :revolutions => Math::PI * 2.0,
      :circle =>  Math::PI * 2.0, :circles =>  Math::PI * 2.0,
      :right_angle =>  Math::PI / 2.0, :right_angles =>  Math::PI / 2.0,
      :grad => Math::PI / 200.0, :grade => Math::PI / 200.0, :gradian => Math::PI / 200.0, :gon => Math::PI / 200.0, :grads => Math::PI / 200.0, :grades => Math::PI / 200.0, :gradians => Math::PI / 200.0, :gons => Math::PI / 200.0,
      #unusual measurements
      :furman => 9.58737992858887e-5, :furmans => 9.58737992858887e-5
    },
    :area => {
      :square_meter => 1.0, :square_meters => 1.0, :square_metre => 1.0, :square_metres => 1.0,
      :acre => 4046.85642, :acres => 4046.85642, 
      :are => 1.0e+2, :ares => 1.0e+2, :a => 1.0e+2,
      :barn => 1.0e-28, :barns => 1.0e-28, :b => 1.0e-28,
      :circular_mil => 5.067075e-10, :circular_mils => 5.067075e-10,
      :hectare => 1.0e+4, :hectares => 1.0e+4, :ha => 1.0e+4,
      :square_foot => 9.290304e-2, :square_feet => 9.290304e-2,
      :square_inch => 6.4516e-4, :square_inches => 6.4516e-4,
      :square_mile => 2.589988e+6, :square_miles => 2.589988e+6,
      :square_yard => 0.83612736, :square_yards => 0.83612736
    },
    :capacitance => {
      :farad => 1.0, :farads => 1.0, :F => 1.0,
      :abfarad => 1.0e+9, :emu_of_capacitance => 1.0e+9, :abfarads => 1.0e+9, :emus_of_capacitance => 1.0e+9,
      :statfarad => 1.112650e-12, :esu_of_capacitance => 1.112650e-12, :statfarads => 1.112650e-12, :esus_of_capacitance => 1.112650e-12
    },
    :density => {
      :specific_gravity => 1, :sg => 1,
      :brix     => [Proc.new{ |d| -261.3 / (d - 261.3) }, Proc.new{ |d| 261.3 - (261.3 / d) }],
      :plato    => [Proc.new{ |d| -260.0 / (d - 260.0) }, Proc.new{ |d| 260.0 - (260.0 / d) }],
      :baume    => [Proc.new{ |d| -145.0 / (d - 145.0) }, Proc.new{ |d| 145.0 - (145.0 / d) }]
    },
    :distance => {
      :meter => 1.0, :metres => 1.0, :meters => 1.0, :m => 1.0,
      :fermi => 1.0e-15, :fermis => 1.0e-15,
      :micron => 1.0e-6, :microns => 1.0e-6,
      :chain => 20.1168, :chains => 20.1168,
      :inch => 25.4e-3, :inches => 25.4e-3, :in => 25.4e-3,
      :microinch => 2.54e-8, :microinches => 2.54e-8,
      :mil => 2.54e-05, :mils => 2.54e-05,
      :rod => 5.029210, :rods => 5.029210,
      :league => 5556, :leagues => 5556,
      :foot => 0.3048, :feet => 0.3048, :ft => 0.3048,
      :yard => 0.9144, :yards => 0.9144, :yd => 0.9144,
      :mile =>1609.344, :miles =>1609.344, :mi => 1609.344,
      :astronomical_unit => 149.60e+9, :astronomical_units => 149.60e+9, :au => 149.60e+9, :ua => 149.60e+9,
      :light_year => 9.461e+15, :light_years => 9.461e+15, :ly => 9.461e+15,
      :parsec => 30.857e+15, :parsecs => 30.857e+15,
      :nautical_mile => 1852.0, :nautical_miles => 1852.0,
      :admirality_mile => 185.3184, :admirality_miles => 185.3184,
      :fathom => 1.8288, :fathoms => 1.8288,
      :cable_length => 185.2, :cable_lengths => 185.2,
      :angstrom => 100.0e-12, :angstroms => 100.0e-12,
      :pica => 4.233333e-3, :picas => 4.233333e-3,
      :printer_pica => 4.217518e-3, :printer_picas => 4.217518e-3,
      :point => 3.527778e-4, :points => 3.527778e-4,
      :printer_point => 3.514598e-4, :printer_points => 3.514598e-4,
      # unusual mesaurements
      :empire_state_building => 449.0, :empire_state_buildings => 449.0,
      :sears_tower => 519.0, :sears_towers => 519.0,
      :seattle_space_needle => 184.0, :seattle_space_needles => 184.0, :space_needle => 184.0, :space_needles => 184.0,
      :statue_of_liberty => 46.0, :statue_of_liberties => 46.0,
      :washington_monument => 169.294, :washington_monuments => 169.294,
      :eiffel_tower => 324.0, :eiffel_towers => 324.0,
      :nelsons_column => 61.5, :nelsons_columns => 61.5,
      :blackpool_tower => 158.0, :blackpool_towers => 158.0,
      :big_ben => 96.3, :big_bens => 96.3, :clock_tower_of_the_palace_of_westminster => 96.3, :clock_towers_of_the_palace_of_westminster => 96.3,
      :st_pauls_cathedral => 108.0, :st_pauls_cathedrals => 108.0,
      :toronto_cn_tower => 553.0, :toronto_cn_towers => 553.0, :cn_tower => 553.0, :cn_towers => 553.0,
      :circle_of_the_earth => 40075016.686, :equator => 40075016.686, :circles_of_the_earth => 40075016.686, :equators => 40075016.686,
      :siriometer => 1.494838e+17, :siriometers => 1.494838e+17,
      :football_field => 91.0, :football_fields => 91.0,
      :length_of_a_double_decker_bus => 8.4, :height_of_a_double_decker_bus => 4.4,
      :smoot => 1.7018, :smoots => 1.7018
    },
    :dose_equivalent => {
      :sievert => 1.0, :sieverts => 1.0, :Si => 1.0,
      :rem => 1.0e-2, :rems => 1.0e-2
    },
    :electric_charge => {
      :coulomb => 1.0, :coulombs => 1.0, :C => 1.0,
      :abcoulomb => 10.0, :abcoulombs => 10.0,
      :ampere_hour => 3.6e+3, :ampere_hours => 3.6e+3,
      :faraday => 9.648534e+4, :faradays => 9.648534e+4,
      :franklin => 3.335641e-10, :franklins => 3.335641e-10, :Fr => 3.335641e-10,
      :statcoulomb => 3.335641e-10, :statcoulombs => 3.335641e-10
    },
    :electric_conductance => {
      :siemen => 1.0, :siemens => 1.0, :S => 1.0, :mho => 1.0,
      :abmho => 1.0e+9, :absiemen => 1.0e+9, :absiemens => 1.0e+9,
      :statmho => 1.112650e-12, :statsiemen => 1.112650e-12, :statsiemens => 1.112650e-12
    },
    :electrical_impedance => {
      :ohm => 1.0, :ohms => 1.0,
      :abohm => 1.0e-9, :emu_of_resistance => 1.0e-9, :abohms => 1.0e-9, :emus_of_resistance => 1.0e-9,
      :statohm => 8.987552e+11, :esu_of_resistance => 8.987552e+11, :statohms => 8.987552e+11, :esus_of_resistance => 8.987552e+11
    },
    :electromotive_force => {
      :volt => 1.0, :volts => 1.0, :V => 1.0,
      :abvolt => 1.0e-8, :emu_of_electric_potential => 1.0e-8, :abvolts => 1.0e-8, :emus_of_electric_potential => 1.0e-8,
      :statvolt => 2.997925e+2, :esu_of_electric_potential => 2.997925e+2, :statvolts => 2.997925e+2, :esus_of_electric_potential => 2.997925e+2
    },
    :energy => {
      :joule => 1.0, :joules => 1.0, :J => 1.0, :watt_second => 1.0, :watt_seconds => 1.0,
      :watt_hour => 3.6e+3, :watt_hours => 3.6e+3,
      :ton_of_tnt => 4.184e+9, :tons_of_tnt => 4.184e+9,
      :therm => 1.05506e+8, :therms => 1.05506e+8,
      :us_therm => 1.054804e+8, :us_therms => 1.054804e+8,
      :kilowatt_hour => 3.6e+6, :kilowatt_hours => 3.6e+6,
      :kilocalorie => 4184.0, :kilocalories => 4184.0,
      :calorie => 4.184, :calories => 4.184,
      :mean_kilocalorie => 4190, :mean_kilocalories => 4190,
      :mean_calorie => 4.190, :mean_calories => 4.190,
      :it_kilocalorie => 4186.8, :it_kilocalories => 4186.8,
      :it_calorie => 4.1868, :it_calories => 4.1868,
      :foot_poundal => 4.214011e-2, :foot_poundals => 4.214011e-2,
      :foot_pound_force => 1.355818,
      :erg =>  1.0e-7, :ergs =>  1.0e-7,
      :electronvolt => 1.602176e-19, :electronvolts => 1.602176e-19, :eV => 1.602176e-19,
      :british_thermal_unit => 1.054350e+3, :british_thermal_units => 1.054350e+3,
      :mean_british_thermal_unit => 1.05587e+3, :mean_british_thermal_units => 1.05587e+3,
      :it_british_thermal_unit => 1.055056e+3, :it_british_thermal_units => 1.055056e+3,
      #unusual measurements
      :foe => 1e+44, :foes => 1e+44
    },
    :force => {
      :newton => 1.0, :newtons => 1.0, :N => 1.0,
      :dyne => 1.0e-5, :dynes => 1.0e-5, :dyn => 1.0e-5,
      :kilogram_force => 9.80665, :kgf => 9.80665, :kilopond => 9.80665, :kiloponds => 9.80665, :kp => 9.80665,
      :kip => 4.448222e+3, :kips => 4.448222e+3,
      :ounce_force => 2.780139e-1, :ozf => 2.780139e-1,
      :poundal => 1.382550e-1, :poundals => 1.382550e-1,
      :pound_force => 4.448222, :lbf => 4.448222,
      :ton_force => 8.896443e+3
    },
    :illuminance => {
      :lux => 1.0, :lx => 1.0, :lumens_per_square_metre => 1.0, :lumens_per_square_meter => 1.0, :lumen_per_square_metre => 1.0, :lumen_per_square_meter => 1.0,
      :phot => 1.0e+4, :phots => 1.0e+4, :ph => 1.0e+4,
      :lumens_per_square_foot => 10.76391, :footcandle => 10.76391, :lumen_per_square_foot => 10.76391, :footcandles => 10.76391
    },
   :inductance => {
      :henry => 1.0, :henrys => 1.0, :H => 1.0,
      :abhenrys => 1.0e-9, :emus_of_inductance => 1.0e-9, :abhenry => 1.0e-9, :emu_of_inductance => 1.0e-9,
      :stathenrys => 8.987552e+11, :esus_of_inductance => 8.987552e+11, :stathenry => 8.987552e+11, :esu_of_inductance => 8.987552e+11
    },
    :information_storage => {
      :bit => 1.0, :bits => 1.0, :b => 1.0,
      :byte => 8.0, :bytes => 8.0, :B => 8.0,
      :nibbles => 4.0, :nybbles => 4.0
    },
    :luminous_flux => {
      :lumen => 1.0, :lumens => 1.0, :lm => 1.0
    },
    :luminous_intensity => {
      :candela => 1.0, :candelas => 1.0, :cd => 1.0
    },
    :magnetic_flux => {
      :webers => 1.0, :Wb => 1.0,
      :maxwells => 1.0e-8, :Mx => 1.0e-8,
      :unit_poles => 1.256637e-7
    },
    :magnetic_inductance => {
      :tesla => 1.0, :teslas => 1.0, :T => 1.0,
      :gamma => 1.0e-9, :gammas => 1.0e-9,
      :gauss => 1.0e-4, :Gs => 1.0e-4, :G => 1.0e-4
    },
    :mass => {
      :gram => 1.0, :gramme => 1.0, :grams => 1.0, :grammes => 1.0, :g => 1.0,
      :carat => 2.0e-1, :carats => 2.0e-1,
      :ounce => 2.834952e+1, :ounces => 2.834952e+1, :oz => 2.834952e+1,
      :pennyweight => 1.555174, :pennyweights => 1.555174, :dwt => 1.555174,
      :pound => 453.59237, :pounds => 453.59237, :lb => 453.59237, :lbs => 453.59237,
      :troy_pound => 373.2417, :apothecary_pound => 373.2417, :troy_pounds => 373.2417, :apothecary_pounds => 373.2417,
      :slug => 14593.9029, :slugs => 14593.9029,
      :assay_ton => 29.1667, :assay_tons => 29.1667, :AT => 29.1667,
      :metric_ton => 1000000, :metric_tons => 1000000,
      :ton => 907184.74, :tons => 907184.74, :short_tons => 907184.74,
      #unusual measurements
      :elephant => 5443108.44, :elephants => 5443108.44
    },
    :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,
      :it_british_thermal_unit_per_hour => 2.930711e-1, :it_british_thermal_units_per_hour => 2.930711e-1,
      :british_thermal_unit_per_second => 1.054350e+3, :british_thermal_units_per_second => 1.054350e+3,
      :it_british_thermal_unit_per_second => 1.055056e+3, :it_british_thermal_units_per_second => 1.055056e+3,
      :calorie_per_minute => 6.973333e-2, :calories_per_minute => 6.973333e-2,
      :calorie_per_second => 4.184, :calories_per_second => 4.184,
      :erg_per_second => 1.0e-7, :ergs_per_second => 1.0e-7,
      :foot_pound_force_per_hour => 3.766161e-4,
      :foot_pound_force_per_minute => 2.259697e-2,
      :foot_pound_force_per_second => 1.355818,
      :horsepower => 7.456999e+2,
      :boiler_horsepower => 9.80950e+3,
      :electric_horsepower => 7.46e+2,
      :metric_horsepower => 7.354988e+2,
      :uk_horsepower => 7.4570e+2,
      :water_horsepower => 7.46043e+2,
      :kilocalorie_per_minute => 6.973333*10, :kilocalories_per_minute => 6.973333*10,
      :kilocalorie_per_second => 4.184e+3, :kilocalories_per_second => 4.184e+3,
      :ton_of_refrigeration => 3.516853e+3, :tons_of_refrigeration => 3.516853e+3
    },
    :pressure => {
      :pascal => 1.0, :pascals => 1.0, :Pa => 1.0,
      :atmosphere => 1.01325e+5, :atmospheres => 1.01325e+5,
      :technical_atmosphere => 9.80665e+4, :technical_atmospheres => 9.80665e+4,
      :bar => 1.0e+5, :bars => 1.0e+5,
      :centimeter_of_mercury => 1.333224e+3, :centimeters_of_mercury => 1.333224e+3,
      :centimeter_of_water => 98.0665, :centimeters_of_water => 98.0665, :gram_force_per_square_centimeter => 98.0665,
      :dyne_per_square_centimeter => 1.0e-1, :dynes_per_square_centimeter => 1.0e-1,
      :foot_of_mercury => 4.063666e+4, :feet_of_mercury => 4.063666e+4,
      :foot_of_water => 2.989067e+3, :feet_of_water => 2.989067e+3,
      :inch_of_mercury => 3.386389e+3, :inches_of_mercury => 3.386389e+3,
      :inch_of_water =>  2.490889e+2, :inches_of_water =>  2.490889e+2,
      :kilogram_force_per_square_centimeter => 9.80665e+4,
      :kilogram_force_per_square_meter => 9.80665,
      :kilogram_force_per_square_millimeter =>  9.80665e+6,
      :kip_per_square_inch => 6.894757e+6, :kips_per_square_inch => 6.894757e+6, :ksi => 6.894757e+6,
      :millibar => 1.0e+2, :mbar => 1.0e+2, :millibars => 1.0e+2, :mbars => 1.0e+2,
      :millimeter_of_mercury => 1.333224e+2, :millimeters_of_mercury => 1.333224e+2,
      :millimeter_of_water => 9.80665, :millimeters_of_water => 9.80665,
      :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
    },
    :radioactivity => {
      :becquerel => 1.0, :becquerels => 1.0, :Bq => 1.0,
      :curie => 3.7e+10, :curies => 3.7e+10, :Ci => 3.7e+10
    },
    :temperature => {
      :kelvin => 1.0, :K => 1.0,
      
      :celsius => [Proc.new{ |t| t + 273.15 }, Proc.new{ |t| t - 273.15 }], :centrigrade => [Proc.new{ |t| t + 273.15 }, Proc.new{ |t| t - 273.15 }],
      :degree_celsius => [Proc.new{ |t| t + 273.15 }, Proc.new{ |t| t - 273.15 }], :degree_centrigrade => [Proc.new{ |t| t + 273.15 }, Proc.new{ |t| t - 273.15 }],
      :degrees_celsius => [Proc.new{ |t| t + 273.15 }, Proc.new{ |t| t - 273.15 }], :degrees_centrigrade => [Proc.new{ |t| t + 273.15 }, Proc.new{ |t| t - 273.15 }],
      :fahrenheit => [Proc.new{ |t| (t + 459.67) * (5.0/9.0) }, Proc.new{ |t| t * (9.0/5.0) - 459.67 }],
      :degree_fahrenheit => [Proc.new{ |t| (t + 459.67) * (5.0/9.0) }, Proc.new{ |t| t * (9.0/5.0) - 459.67 }],
      :degrees_fahrenheit => [Proc.new{ |t| (t + 459.67) * (5.0/9.0) }, Proc.new{ |t| t * (9.0/5.0) - 459.67 }],
      :rankine => 1.8, :rankines => 1.8
    }, 
    :time => {
      :second => 1.0, :seconds => 1.0, :s => 1.0,
      :minute => 60.0, :minutes => 60.0, :min => 60.0,
      :sidereal_minute => 5.983617, :sidereal_minutes => 5.983617,
      :hour => 3600.0, :hours => 3600.0, :hr => 3600.0, :h => 3600.0,
      :sidereal_hour => 3.590170e+3, :sidereal_hours => 3.590170e+3,
      :day => 86400.0, :days => 86400.0,
      :sidereal_day => 8.616409e+4, :sidereal_days => 8.616409e+4,
      :shake => 1.0e-8, :shakes => 1.0e-8,
      :year => 3.1536e+7, :years => 3.1536e+7,
      :sidereal_year => 3.155815e+7, :sidereal_years => 3.155815e+7,
      :tropical_year => 3.155693e+7, :tropical_years => 3.155693e+7,
      #unusual measurements
      :jiffy => 0.01, :jiffies => 0.01,
      :microfortnight => 1.2096, :microfortnights => 1.2096,
      :megaannum => 3.1536e+16, :Ma => 3.1536e+16, :megaannums => 3.1536e+16,
      :galactic_year => 7.884e+18, :galactic_years => 7.884e+18, :GY => 7.884e+18
    },
    :volume => {
      :litre => 1.0, :liter => 1.0, :litres => 1.0, :liters => 1.0, :l => 1.0, :L => 1.0,
      :barrel => 1.589873e+2, :barrels => 1.589873e+2,
      :bushel => 3.523907e+1, :bushels => 3.523907e+1,
      :cubic_meter => 1000.0, :cubic_meters => 1000.0,
      :cup => 2.365882e-1, :cups => 2.365882e-1,
      :imperial_fluid_ounce => 0.0284130742, :imperial_fluid_ounces => 0.0284130742,
      :ounce => 0.0295735296, :ounces => 0.0295735296, :fluid_ounce => 0.0295735296, :fluid_ounces => 0.0295735296,
      :imperial_gallon => 4.54609, :imperial_gallons => 4.54609,
      :gallon => 3.785412, :gallons => 3.785412, :gals => 3.785412, :Gals => 3.785412,
      :imperial_gill => 1.420653e-1, :imperial_gills => 1.420653e-1,
      :gill => 1.182941e-1, :gills => 1.182941e-1, :gi => 1.182941e-1,
      :pint => 5.506105e-1, :pints => 5.506105e-1,
      :liquid_pint => 4.731765e-1, :liquid_pints => 4.731765e-1,
      :quart => 1.101221, :quarts => 1.101221,
      :liquid_quart => 9.463529e-1, :liquid_quarts => 9.463529e-1,
      :tablespoon => 0.0147867648, :tablespoons => 0.0147867648,
      :teaspoon => 0.00492892159, :teaspoons => 0.00492892159,
      #unusual measurements
      :sydharb => 5.0e+11, :sydharbs => 5.0e+11
    }
  }
end