ruby-units 4.0.2 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +9 -5
- data/.rubocop.yml +12 -8
- data/.rubocop_todo.yml +193 -0
- data/.ruby-version +1 -1
- data/.tool-versions +1 -1
- data/Gemfile +19 -17
- data/Gemfile.lock +47 -49
- data/Guardfile +7 -5
- data/README.md +9 -4
- data/Rakefile +4 -2
- data/lib/ruby-units.rb +3 -1
- data/lib/ruby_units/array.rb +2 -0
- data/lib/ruby_units/cache.rb +2 -0
- data/lib/ruby_units/configuration.rb +31 -1
- data/lib/ruby_units/date.rb +7 -5
- data/lib/ruby_units/definition.rb +5 -4
- data/lib/ruby_units/math.rb +13 -11
- data/lib/ruby_units/namespaced.rb +14 -12
- data/lib/ruby_units/numeric.rb +2 -0
- data/lib/ruby_units/string.rb +3 -1
- data/lib/ruby_units/time.rb +11 -9
- data/lib/ruby_units/unit.rb +142 -116
- data/lib/ruby_units/unit_definitions/base.rb +17 -15
- data/lib/ruby_units/unit_definitions/prefix.rb +32 -30
- data/lib/ruby_units/unit_definitions/standard.rb +275 -270
- data/lib/ruby_units/unit_definitions.rb +5 -3
- data/lib/ruby_units/version.rb +3 -1
- metadata +4 -3
@@ -1,255 +1,260 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# length units
|
2
4
|
|
3
|
-
RubyUnits::Unit.define(
|
4
|
-
inch.definition = RubyUnits::Unit.new(
|
5
|
+
RubyUnits::Unit.define("inch") do |inch|
|
6
|
+
inch.definition = RubyUnits::Unit.new("254/10000 meter")
|
5
7
|
inch.aliases = %w[in inch inches "]
|
6
8
|
end
|
7
9
|
|
8
|
-
RubyUnits::Unit.define(
|
9
|
-
foot.definition = RubyUnits::Unit.new(
|
10
|
+
RubyUnits::Unit.define("foot") do |foot|
|
11
|
+
foot.definition = RubyUnits::Unit.new("12 inches")
|
10
12
|
foot.aliases = %w[ft foot feet ']
|
11
13
|
end
|
12
14
|
|
13
|
-
RubyUnits::Unit.define(
|
14
|
-
sft.definition = RubyUnits::Unit.new(
|
15
|
+
RubyUnits::Unit.define("survey-foot") do |sft|
|
16
|
+
sft.definition = RubyUnits::Unit.new("1200/3937 meter")
|
15
17
|
sft.aliases = %w[sft sfoot sfeet]
|
16
18
|
end
|
17
19
|
|
18
|
-
RubyUnits::Unit.define(
|
19
|
-
yard.definition = RubyUnits::Unit.new(
|
20
|
+
RubyUnits::Unit.define("yard") do |yard|
|
21
|
+
yard.definition = RubyUnits::Unit.new("3 ft")
|
20
22
|
yard.aliases = %w[yd yard yards]
|
21
23
|
end
|
22
24
|
|
23
|
-
RubyUnits::Unit.define(
|
24
|
-
mile.definition = RubyUnits::Unit.new(
|
25
|
+
RubyUnits::Unit.define("mile") do |mile|
|
26
|
+
mile.definition = RubyUnits::Unit.new("5280 ft")
|
25
27
|
mile.aliases = %w[mi mile miles]
|
26
28
|
end
|
27
29
|
|
28
|
-
RubyUnits::Unit.define(
|
29
|
-
naut.definition = RubyUnits::Unit.new(
|
30
|
-
naut.aliases = %w[nmi
|
30
|
+
RubyUnits::Unit.define("naut-mile") do |naut|
|
31
|
+
naut.definition = RubyUnits::Unit.new("1852 m")
|
32
|
+
naut.aliases = %w[nmi NM]
|
33
|
+
# Don't use the 'M' abbreviation here since it conflicts with 'Molar'
|
31
34
|
end
|
32
35
|
|
33
36
|
# on land
|
34
|
-
RubyUnits::Unit.define(
|
35
|
-
league.definition = RubyUnits::Unit.new(
|
37
|
+
RubyUnits::Unit.define("league") do |league|
|
38
|
+
league.definition = RubyUnits::Unit.new("3 miles")
|
36
39
|
league.aliases = %w[league leagues]
|
37
40
|
end
|
38
41
|
|
39
42
|
# at sea
|
40
|
-
RubyUnits::Unit.define(
|
41
|
-
naut_league.definition = RubyUnits::Unit.new(
|
43
|
+
RubyUnits::Unit.define("naut-league") do |naut_league|
|
44
|
+
naut_league.definition = RubyUnits::Unit.new("3 nmi")
|
42
45
|
naut_league.aliases = %w[nleague nleagues]
|
43
46
|
end
|
44
47
|
|
45
|
-
RubyUnits::Unit.define(
|
46
|
-
furlong.definition = RubyUnits::Unit.new(
|
48
|
+
RubyUnits::Unit.define("furlong") do |furlong|
|
49
|
+
furlong.definition = RubyUnits::Unit.new("1/8 mile")
|
47
50
|
furlong.aliases = %w[fur furlong furlongs]
|
48
51
|
end
|
49
52
|
|
50
|
-
RubyUnits::Unit.define(
|
51
|
-
rod.definition = RubyUnits::Unit.new(
|
53
|
+
RubyUnits::Unit.define("rod") do |rod|
|
54
|
+
rod.definition = RubyUnits::Unit.new("33/2 feet")
|
52
55
|
rod.aliases = %w[rd rod rods]
|
53
56
|
end
|
54
57
|
|
55
|
-
RubyUnits::Unit.define(
|
56
|
-
fathom.definition = RubyUnits::Unit.new(
|
58
|
+
RubyUnits::Unit.define("fathom") do |fathom|
|
59
|
+
fathom.definition = RubyUnits::Unit.new("6 ft")
|
57
60
|
fathom.aliases = %w[fathom fathoms]
|
58
61
|
end
|
59
62
|
|
60
|
-
RubyUnits::Unit.define(
|
61
|
-
mil.definition = RubyUnits::Unit.new(
|
63
|
+
RubyUnits::Unit.define("mil") do |mil|
|
64
|
+
mil.definition = RubyUnits::Unit.new("1/1000 inch")
|
62
65
|
mil.aliases = %w[mil mils]
|
63
66
|
end
|
64
67
|
|
65
|
-
RubyUnits::Unit.define(
|
66
|
-
ang.definition = RubyUnits::Unit.new(
|
68
|
+
RubyUnits::Unit.define("angstrom") do |ang|
|
69
|
+
ang.definition = RubyUnits::Unit.new("1/10 nm")
|
67
70
|
ang.aliases = %w[ang angstrom angstroms]
|
68
71
|
end
|
69
72
|
|
70
73
|
# typesetting
|
71
74
|
|
72
|
-
RubyUnits::Unit.define(
|
73
|
-
pica.definition = RubyUnits::Unit.new(
|
74
|
-
pica.aliases = %w[
|
75
|
+
RubyUnits::Unit.define("pica") do |pica|
|
76
|
+
pica.definition = RubyUnits::Unit.new("1/72 ft")
|
77
|
+
pica.aliases = %w[pica picas]
|
78
|
+
# Don't use 'P' as an abbreviation since it conflicts with 'Poise'
|
79
|
+
# Don't use 'pc' as an abbreviation since it conflicts with 'parsec'
|
75
80
|
end
|
76
81
|
|
77
|
-
RubyUnits::Unit.define(
|
78
|
-
point.definition = RubyUnits::Unit.new(
|
82
|
+
RubyUnits::Unit.define("point") do |point|
|
83
|
+
point.definition = RubyUnits::Unit.new("1/12 pica")
|
79
84
|
point.aliases = %w[point points]
|
80
85
|
end
|
81
86
|
|
82
|
-
RubyUnits::Unit.define(
|
83
|
-
dot.definition = RubyUnits::Unit.new(
|
87
|
+
RubyUnits::Unit.define("dot") do |dot|
|
88
|
+
dot.definition = RubyUnits::Unit.new("1 each")
|
84
89
|
dot.aliases = %w[dot dots]
|
85
90
|
dot.kind = :counting
|
86
91
|
end
|
87
92
|
|
88
|
-
RubyUnits::Unit.define(
|
89
|
-
pixel.definition = RubyUnits::Unit.new(
|
93
|
+
RubyUnits::Unit.define("pixel") do |pixel|
|
94
|
+
pixel.definition = RubyUnits::Unit.new("1 each")
|
90
95
|
pixel.aliases = %w[px pixel pixels]
|
91
96
|
pixel.kind = :counting
|
92
97
|
end
|
93
98
|
|
94
|
-
RubyUnits::Unit.define(
|
95
|
-
ppi.definition = RubyUnits::Unit.new(
|
99
|
+
RubyUnits::Unit.define("ppi") do |ppi|
|
100
|
+
ppi.definition = RubyUnits::Unit.new("1 pixel/inch")
|
96
101
|
end
|
97
102
|
|
98
|
-
RubyUnits::Unit.define(
|
99
|
-
dpi.definition = RubyUnits::Unit.new(
|
103
|
+
RubyUnits::Unit.define("dpi") do |dpi|
|
104
|
+
dpi.definition = RubyUnits::Unit.new("1 dot/inch")
|
100
105
|
end
|
101
106
|
|
102
107
|
# Mass
|
103
108
|
|
104
|
-
avagadro_constant = RubyUnits::Unit.new(
|
109
|
+
avagadro_constant = RubyUnits::Unit.new("6.02214129e23 1/mol")
|
105
110
|
|
106
|
-
RubyUnits::Unit.define(
|
107
|
-
amu.definition = RubyUnits::Unit.new(
|
111
|
+
RubyUnits::Unit.define("AMU") do |amu|
|
112
|
+
amu.definition = RubyUnits::Unit.new("0.012 kg/mol") / (12 * avagadro_constant)
|
108
113
|
amu.aliases = %w[u AMU amu]
|
109
114
|
end
|
110
115
|
|
111
|
-
RubyUnits::Unit.define(
|
112
|
-
dalton.definition = RubyUnits::Unit.new(
|
116
|
+
RubyUnits::Unit.define("dalton") do |dalton|
|
117
|
+
dalton.definition = RubyUnits::Unit.new("1 amu")
|
113
118
|
dalton.aliases = %w[Da dalton daltons]
|
114
119
|
end
|
115
120
|
|
116
|
-
RubyUnits::Unit.define(
|
117
|
-
mton.definition = RubyUnits::Unit.new(
|
121
|
+
RubyUnits::Unit.define("metric-ton") do |mton|
|
122
|
+
mton.definition = RubyUnits::Unit.new("1000 kg")
|
118
123
|
mton.aliases = %w[tonne]
|
119
124
|
end
|
120
125
|
|
121
126
|
# defined as a rational number to preserve accuracy and minimize round-off errors during
|
122
127
|
# calculations
|
123
|
-
RubyUnits::Unit.define(
|
124
|
-
pound.definition = RubyUnits::Unit.new(Rational(45_359_237, 1e8),
|
128
|
+
RubyUnits::Unit.define("pound") do |pound|
|
129
|
+
pound.definition = RubyUnits::Unit.new(Rational(45_359_237, 1e8), "kg")
|
125
130
|
pound.aliases = %w[lbs lb lbm pound-mass pound pounds #]
|
126
131
|
end
|
127
132
|
|
128
|
-
RubyUnits::Unit.define(
|
129
|
-
ounce.definition = RubyUnits::Unit.new(
|
133
|
+
RubyUnits::Unit.define("ounce") do |ounce|
|
134
|
+
ounce.definition = RubyUnits::Unit.new("1/16 lbs")
|
130
135
|
ounce.aliases = %w[oz ounce ounces]
|
131
136
|
end
|
132
137
|
|
133
|
-
RubyUnits::Unit.define(
|
134
|
-
gram.definition = RubyUnits::Unit.new(
|
138
|
+
RubyUnits::Unit.define("gram") do |gram|
|
139
|
+
gram.definition = RubyUnits::Unit.new("1/1000 kg")
|
135
140
|
gram.aliases = %w[g gram grams gramme grammes]
|
136
141
|
end
|
137
142
|
|
138
|
-
RubyUnits::Unit.define(
|
139
|
-
ton.definition = RubyUnits::Unit.new(
|
143
|
+
RubyUnits::Unit.define("short-ton") do |ton|
|
144
|
+
ton.definition = RubyUnits::Unit.new("2000 lbs")
|
140
145
|
ton.aliases = %w[tn ton tons short-tons]
|
141
146
|
end
|
142
147
|
|
143
|
-
RubyUnits::Unit.define(
|
144
|
-
carat.definition = RubyUnits::Unit.new(
|
148
|
+
RubyUnits::Unit.define("carat") do |carat|
|
149
|
+
carat.definition = RubyUnits::Unit.new("1/5000 kg")
|
145
150
|
carat.aliases = %w[ct carat carats]
|
146
151
|
end
|
147
152
|
|
148
|
-
RubyUnits::Unit.define(
|
149
|
-
stone.definition = RubyUnits::Unit.new(
|
153
|
+
RubyUnits::Unit.define("stone") do |stone|
|
154
|
+
stone.definition = RubyUnits::Unit.new("14 lbs")
|
150
155
|
stone.aliases = %w[st stone]
|
151
156
|
end
|
152
157
|
|
153
158
|
# time
|
154
159
|
|
155
|
-
RubyUnits::Unit.define(
|
156
|
-
min.definition = RubyUnits::Unit.new(
|
160
|
+
RubyUnits::Unit.define("minute") do |min|
|
161
|
+
min.definition = RubyUnits::Unit.new("60 seconds")
|
157
162
|
min.aliases = %w[min minute minutes]
|
158
163
|
end
|
159
164
|
|
160
|
-
RubyUnits::Unit.define(
|
161
|
-
hour.definition = RubyUnits::Unit.new(
|
165
|
+
RubyUnits::Unit.define("hour") do |hour|
|
166
|
+
hour.definition = RubyUnits::Unit.new("60 minutes")
|
162
167
|
hour.aliases = %w[h hr hrs hour hours]
|
163
168
|
end
|
164
169
|
|
165
|
-
RubyUnits::Unit.define(
|
166
|
-
day.definition = RubyUnits::Unit.new(
|
170
|
+
RubyUnits::Unit.define("day") do |day|
|
171
|
+
day.definition = RubyUnits::Unit.new("24 hours")
|
167
172
|
day.aliases = %w[d day days]
|
168
173
|
end
|
169
174
|
|
170
|
-
RubyUnits::Unit.define(
|
171
|
-
week.definition = RubyUnits::Unit.new(
|
175
|
+
RubyUnits::Unit.define("week") do |week|
|
176
|
+
week.definition = RubyUnits::Unit.new("7 days")
|
172
177
|
week.aliases = %w[wk week weeks]
|
173
178
|
end
|
174
179
|
|
175
|
-
RubyUnits::Unit.define(
|
176
|
-
fortnight.definition = RubyUnits::Unit.new(
|
180
|
+
RubyUnits::Unit.define("fortnight") do |fortnight|
|
181
|
+
fortnight.definition = RubyUnits::Unit.new("2 weeks")
|
177
182
|
fortnight.aliases = %w[fortnight fortnights]
|
178
183
|
end
|
179
184
|
|
180
|
-
RubyUnits::Unit.define(
|
181
|
-
year.definition = RubyUnits::Unit.new(
|
185
|
+
RubyUnits::Unit.define("year") do |year|
|
186
|
+
year.definition = RubyUnits::Unit.new("31556926 seconds") # works out to 365.24219907407405 days
|
182
187
|
year.aliases = %w[y yr year years annum]
|
183
188
|
end
|
184
189
|
|
185
|
-
RubyUnits::Unit.define(
|
186
|
-
decade.definition = RubyUnits::Unit.new(
|
190
|
+
RubyUnits::Unit.define("decade") do |decade|
|
191
|
+
decade.definition = RubyUnits::Unit.new("10 years")
|
187
192
|
decade.aliases = %w[decade decades]
|
188
193
|
end
|
189
194
|
|
190
|
-
RubyUnits::Unit.define(
|
191
|
-
century.definition = RubyUnits::Unit.new(
|
195
|
+
RubyUnits::Unit.define("century") do |century|
|
196
|
+
century.definition = RubyUnits::Unit.new("100 years")
|
192
197
|
century.aliases = %w[century centuries]
|
193
198
|
end
|
194
199
|
|
195
200
|
# area
|
196
201
|
|
197
|
-
RubyUnits::Unit.define(
|
198
|
-
hectare.definition = RubyUnits::Unit.new(
|
202
|
+
RubyUnits::Unit.define("hectare") do |hectare|
|
203
|
+
hectare.definition = RubyUnits::Unit.new("10000 m^2")
|
199
204
|
end
|
200
205
|
|
201
|
-
RubyUnits::Unit.define(
|
202
|
-
acre.definition = RubyUnits::Unit.new(
|
206
|
+
RubyUnits::Unit.define("acre") do |acre|
|
207
|
+
acre.definition = (RubyUnits::Unit.new("1 mi")**2) / 640
|
203
208
|
acre.aliases = %w[acre acres]
|
204
209
|
end
|
205
210
|
|
206
|
-
RubyUnits::Unit.define(
|
207
|
-
sqft.definition = RubyUnits::Unit.new(
|
211
|
+
RubyUnits::Unit.define("sqft") do |sqft|
|
212
|
+
sqft.definition = RubyUnits::Unit.new("1 ft^2")
|
208
213
|
end
|
209
214
|
|
210
|
-
RubyUnits::Unit.define(
|
211
|
-
sqin.definition = RubyUnits::Unit.new(
|
215
|
+
RubyUnits::Unit.define("sqin") do |sqin|
|
216
|
+
sqin.definition = RubyUnits::Unit.new("1 in^2")
|
212
217
|
end
|
213
218
|
|
214
219
|
# volume
|
215
220
|
|
216
|
-
RubyUnits::Unit.define(
|
217
|
-
liter.definition = RubyUnits::Unit.new(
|
221
|
+
RubyUnits::Unit.define("liter") do |liter|
|
222
|
+
liter.definition = RubyUnits::Unit.new("1/1000 m^3")
|
218
223
|
liter.aliases = %w[l L liter liters litre litres]
|
219
224
|
end
|
220
225
|
|
221
|
-
RubyUnits::Unit.define(
|
222
|
-
gallon.definition = RubyUnits::Unit.new(
|
226
|
+
RubyUnits::Unit.define("gallon") do |gallon|
|
227
|
+
gallon.definition = RubyUnits::Unit.new("231 in^3")
|
223
228
|
gallon.aliases = %w[gal gallon gallons]
|
224
229
|
end
|
225
230
|
|
226
|
-
RubyUnits::Unit.define(
|
227
|
-
quart.definition = RubyUnits::Unit.new(
|
231
|
+
RubyUnits::Unit.define("quart") do |quart|
|
232
|
+
quart.definition = RubyUnits::Unit.new("1/4 gal")
|
228
233
|
quart.aliases = %w[qt quart quarts]
|
229
234
|
end
|
230
235
|
|
231
|
-
RubyUnits::Unit.define(
|
232
|
-
pint.definition = RubyUnits::Unit.new(
|
236
|
+
RubyUnits::Unit.define("pint") do |pint|
|
237
|
+
pint.definition = RubyUnits::Unit.new("1/8 gal")
|
233
238
|
pint.aliases = %w[pt pint pints]
|
234
239
|
end
|
235
240
|
|
236
|
-
RubyUnits::Unit.define(
|
237
|
-
cup.definition = RubyUnits::Unit.new(
|
241
|
+
RubyUnits::Unit.define("cup") do |cup|
|
242
|
+
cup.definition = RubyUnits::Unit.new("1/16 gal")
|
238
243
|
cup.aliases = %w[cu cup cups]
|
239
244
|
end
|
240
245
|
|
241
|
-
RubyUnits::Unit.define(
|
242
|
-
floz.definition = RubyUnits::Unit.new(
|
246
|
+
RubyUnits::Unit.define("fluid-ounce") do |floz|
|
247
|
+
floz.definition = RubyUnits::Unit.new("1/128 gal")
|
243
248
|
floz.aliases = %w[floz fluid-ounce fluid-ounces]
|
244
249
|
end
|
245
250
|
|
246
|
-
RubyUnits::Unit.define(
|
247
|
-
tbsp.definition = RubyUnits::Unit.new(
|
251
|
+
RubyUnits::Unit.define("tablespoon") do |tbsp|
|
252
|
+
tbsp.definition = RubyUnits::Unit.new("1/2 floz")
|
248
253
|
tbsp.aliases = %w[tbs tbsp tablespoon tablespoons]
|
249
254
|
end
|
250
255
|
|
251
|
-
RubyUnits::Unit.define(
|
252
|
-
tsp.definition = RubyUnits::Unit.new(
|
256
|
+
RubyUnits::Unit.define("teaspoon") do |tsp|
|
257
|
+
tsp.definition = RubyUnits::Unit.new("1/3 tablespoon")
|
253
258
|
tsp.aliases = %w[tsp teaspoon teaspoons]
|
254
259
|
end
|
255
260
|
|
@@ -258,461 +263,461 @@ end
|
|
258
263
|
# the United States and Canada. It is the volume of a one-foot length of a board
|
259
264
|
# one foot wide and one inch thick.
|
260
265
|
# http://en.wikipedia.org/wiki/Board_foot
|
261
|
-
RubyUnits::Unit.define(
|
262
|
-
bdft.definition = RubyUnits::Unit.new(
|
266
|
+
RubyUnits::Unit.define("bdft") do |bdft|
|
267
|
+
bdft.definition = RubyUnits::Unit.new("1/12 ft^3")
|
263
268
|
bdft.aliases = %w[fbm boardfoot boardfeet bf]
|
264
269
|
end
|
265
270
|
|
266
271
|
# volumetric flow
|
267
272
|
|
268
|
-
RubyUnits::Unit.define(
|
269
|
-
cfm.definition = RubyUnits::Unit.new(
|
273
|
+
RubyUnits::Unit.define("cfm") do |cfm|
|
274
|
+
cfm.definition = RubyUnits::Unit.new("1 ft^3/minute")
|
270
275
|
cfm.aliases = %w[cfm CFM CFPM]
|
271
276
|
end
|
272
277
|
|
273
278
|
# speed
|
274
279
|
|
275
|
-
RubyUnits::Unit.define(
|
276
|
-
kph.definition = RubyUnits::Unit.new(
|
280
|
+
RubyUnits::Unit.define("kph") do |kph|
|
281
|
+
kph.definition = RubyUnits::Unit.new("1 kilometer/hour")
|
277
282
|
end
|
278
283
|
|
279
|
-
RubyUnits::Unit.define(
|
280
|
-
mph.definition = RubyUnits::Unit.new(
|
284
|
+
RubyUnits::Unit.define("mph") do |mph|
|
285
|
+
mph.definition = RubyUnits::Unit.new("1 mile/hour")
|
281
286
|
end
|
282
287
|
|
283
|
-
RubyUnits::Unit.define(
|
284
|
-
fps.definition = RubyUnits::Unit.new(
|
288
|
+
RubyUnits::Unit.define("fps") do |fps|
|
289
|
+
fps.definition = RubyUnits::Unit.new("1 foot/second")
|
285
290
|
end
|
286
291
|
|
287
|
-
RubyUnits::Unit.define(
|
288
|
-
knot.definition = RubyUnits::Unit.new(
|
292
|
+
RubyUnits::Unit.define("knot") do |knot|
|
293
|
+
knot.definition = RubyUnits::Unit.new("1 nmi/hour")
|
289
294
|
knot.aliases = %w[kt kn kts knot knots]
|
290
295
|
end
|
291
296
|
|
292
|
-
RubyUnits::Unit.define(
|
297
|
+
RubyUnits::Unit.define("gee") do |gee|
|
293
298
|
# approximated as a rational number to minimize round-off errors
|
294
|
-
gee.definition = RubyUnits::Unit.new(Rational(196_133, 20_000),
|
299
|
+
gee.definition = RubyUnits::Unit.new(Rational(196_133, 20_000), "m/s^2") # equivalent to 9.80665 m/s^2
|
295
300
|
gee.aliases = %w[gee standard-gravitation]
|
296
301
|
end
|
297
302
|
|
298
303
|
# temperature differences
|
299
304
|
|
300
|
-
RubyUnits::Unit.define(
|
301
|
-
newton.definition = RubyUnits::Unit.new(
|
305
|
+
RubyUnits::Unit.define("newton") do |newton|
|
306
|
+
newton.definition = RubyUnits::Unit.new("1 kg*m/s^2")
|
302
307
|
newton.aliases = %w[N newton newtons]
|
303
308
|
end
|
304
309
|
|
305
|
-
RubyUnits::Unit.define(
|
306
|
-
dyne.definition = RubyUnits::Unit.new(
|
310
|
+
RubyUnits::Unit.define("dyne") do |dyne|
|
311
|
+
dyne.definition = RubyUnits::Unit.new("1/100000 N")
|
307
312
|
dyne.aliases = %w[dyn dyne]
|
308
313
|
end
|
309
314
|
|
310
|
-
RubyUnits::Unit.define(
|
311
|
-
lbf.definition = RubyUnits::Unit.new(
|
315
|
+
RubyUnits::Unit.define("pound-force") do |lbf|
|
316
|
+
lbf.definition = RubyUnits::Unit.new("1 lb") * RubyUnits::Unit.new("1 gee")
|
312
317
|
lbf.aliases = %w[lbf pound-force]
|
313
318
|
end
|
314
319
|
|
315
|
-
RubyUnits::Unit.define(
|
316
|
-
poundal.definition = RubyUnits::Unit.new(
|
320
|
+
RubyUnits::Unit.define("poundal") do |poundal|
|
321
|
+
poundal.definition = RubyUnits::Unit.new("1 lb") * RubyUnits::Unit.new("1 ft/s^2")
|
317
322
|
poundal.aliases = %w[pdl poundal poundals]
|
318
323
|
end
|
319
324
|
|
320
325
|
temp_convert_factor = Rational(2_501_999_792_983_609, 4_503_599_627_370_496) # approximates 1/1.8
|
321
326
|
|
322
|
-
RubyUnits::Unit.define(
|
323
|
-
celsius.definition = RubyUnits::Unit.new(
|
327
|
+
RubyUnits::Unit.define("celsius") do |celsius|
|
328
|
+
celsius.definition = RubyUnits::Unit.new("1 degK")
|
324
329
|
celsius.aliases = %w[degC celsius centigrade]
|
325
330
|
end
|
326
331
|
|
327
|
-
RubyUnits::Unit.define(
|
328
|
-
fahrenheit.definition = RubyUnits::Unit.new(temp_convert_factor,
|
332
|
+
RubyUnits::Unit.define("fahrenheit") do |fahrenheit|
|
333
|
+
fahrenheit.definition = RubyUnits::Unit.new(temp_convert_factor, "degK")
|
329
334
|
fahrenheit.aliases = %w[degF fahrenheit]
|
330
335
|
end
|
331
336
|
|
332
|
-
RubyUnits::Unit.define(
|
333
|
-
rankine.definition = RubyUnits::Unit.new(
|
337
|
+
RubyUnits::Unit.define("rankine") do |rankine|
|
338
|
+
rankine.definition = RubyUnits::Unit.new("1 degF")
|
334
339
|
rankine.aliases = %w[degR rankine]
|
335
340
|
end
|
336
341
|
|
337
|
-
RubyUnits::Unit.define(
|
338
|
-
temp_c.definition = RubyUnits::Unit.new(
|
342
|
+
RubyUnits::Unit.define("tempC") do |temp_c|
|
343
|
+
temp_c.definition = RubyUnits::Unit.new("1 tempK")
|
339
344
|
end
|
340
345
|
|
341
|
-
RubyUnits::Unit.define(
|
342
|
-
temp_f.definition = RubyUnits::Unit.new(temp_convert_factor,
|
346
|
+
RubyUnits::Unit.define("tempF") do |temp_f|
|
347
|
+
temp_f.definition = RubyUnits::Unit.new(temp_convert_factor, "tempK")
|
343
348
|
end
|
344
349
|
|
345
|
-
RubyUnits::Unit.define(
|
346
|
-
temp_r.definition = RubyUnits::Unit.new(
|
350
|
+
RubyUnits::Unit.define("tempR") do |temp_r|
|
351
|
+
temp_r.definition = RubyUnits::Unit.new("1 tempF")
|
347
352
|
end
|
348
353
|
|
349
354
|
# astronomy
|
350
355
|
|
351
|
-
speed_of_light = RubyUnits::Unit.new(
|
356
|
+
speed_of_light = RubyUnits::Unit.new("299792458 m/s")
|
352
357
|
|
353
|
-
RubyUnits::Unit.define(
|
354
|
-
ls.definition = RubyUnits::Unit.new(
|
358
|
+
RubyUnits::Unit.define("light-second") do |ls|
|
359
|
+
ls.definition = RubyUnits::Unit.new("1 s") * speed_of_light
|
355
360
|
ls.aliases = %w[ls lsec light-second]
|
356
361
|
end
|
357
362
|
|
358
|
-
RubyUnits::Unit.define(
|
359
|
-
lmin.definition = RubyUnits::Unit.new(
|
363
|
+
RubyUnits::Unit.define("light-minute") do |lmin|
|
364
|
+
lmin.definition = RubyUnits::Unit.new("1 min") * speed_of_light
|
360
365
|
lmin.aliases = %w[lmin light-minute]
|
361
366
|
end
|
362
367
|
|
363
|
-
RubyUnits::Unit.define(
|
364
|
-
ly.definition = RubyUnits::Unit.new(
|
368
|
+
RubyUnits::Unit.define("light-year") do |ly|
|
369
|
+
ly.definition = RubyUnits::Unit.new("1 y") * speed_of_light
|
365
370
|
ly.aliases = %w[ly light-year]
|
366
371
|
end
|
367
372
|
|
368
|
-
RubyUnits::Unit.define(
|
369
|
-
parsec.definition = RubyUnits::Unit.new(
|
373
|
+
RubyUnits::Unit.define("parsec") do |parsec|
|
374
|
+
parsec.definition = RubyUnits::Unit.new("3.26163626 ly")
|
370
375
|
parsec.aliases = %w[pc parsec parsecs]
|
371
376
|
end
|
372
377
|
|
373
378
|
# once was '149597900000 m' but there appears to be a more accurate estimate according to wikipedia
|
374
379
|
# see http://en.wikipedia.org/wiki/Astronomical_unit
|
375
|
-
RubyUnits::Unit.define(
|
376
|
-
au.definition = RubyUnits::Unit.new(
|
380
|
+
RubyUnits::Unit.define("AU") do |au|
|
381
|
+
au.definition = RubyUnits::Unit.new("149597870700 m")
|
377
382
|
au.aliases = %w[AU astronomical-unit]
|
378
383
|
end
|
379
384
|
|
380
|
-
RubyUnits::Unit.define(
|
381
|
-
red.definition = RubyUnits::Unit.new(
|
385
|
+
RubyUnits::Unit.define("redshift") do |red|
|
386
|
+
red.definition = RubyUnits::Unit.new("1.302773e26 m")
|
382
387
|
red.aliases = %w[z red-shift]
|
383
388
|
end
|
384
389
|
|
385
390
|
# mass
|
386
391
|
|
387
|
-
RubyUnits::Unit.define(
|
388
|
-
slug.definition = RubyUnits::Unit.new(
|
392
|
+
RubyUnits::Unit.define("slug") do |slug|
|
393
|
+
slug.definition = RubyUnits::Unit.new("1 lbf*s^2/ft")
|
389
394
|
slug.aliases = %w[slug slugs]
|
390
395
|
end
|
391
396
|
|
392
397
|
# pressure
|
393
398
|
|
394
|
-
RubyUnits::Unit.define(
|
395
|
-
pascal.definition = RubyUnits::Unit.new(
|
399
|
+
RubyUnits::Unit.define("pascal") do |pascal|
|
400
|
+
pascal.definition = RubyUnits::Unit.new("1 kg/m*s^2")
|
396
401
|
pascal.aliases = %w[Pa pascal pascals]
|
397
402
|
end
|
398
403
|
|
399
|
-
RubyUnits::Unit.define(
|
400
|
-
bar.definition = RubyUnits::Unit.new(
|
404
|
+
RubyUnits::Unit.define("bar") do |bar|
|
405
|
+
bar.definition = RubyUnits::Unit.new("100 kPa")
|
401
406
|
bar.aliases = %w[bar bars]
|
402
407
|
end
|
403
408
|
|
404
|
-
RubyUnits::Unit.define(
|
405
|
-
atm.definition = RubyUnits::Unit.new(
|
409
|
+
RubyUnits::Unit.define("atm") do |atm|
|
410
|
+
atm.definition = RubyUnits::Unit.new("101325 Pa")
|
406
411
|
atm.aliases = %w[atm ATM atmosphere atmospheres]
|
407
412
|
end
|
408
413
|
|
409
|
-
RubyUnits::Unit.define(
|
410
|
-
density_of_mercury = RubyUnits::Unit.new(
|
411
|
-
mmhg.definition = RubyUnits::Unit.new(
|
414
|
+
RubyUnits::Unit.define("mmHg") do |mmhg|
|
415
|
+
density_of_mercury = RubyUnits::Unit.new("7653360911758079/562949953421312 g/cm^3") # 13.5951 g/cm^3 at 0 tempC
|
416
|
+
mmhg.definition = RubyUnits::Unit.new("1 mm") * RubyUnits::Unit.new("1 gee") * density_of_mercury
|
412
417
|
end
|
413
418
|
|
414
|
-
RubyUnits::Unit.define(
|
415
|
-
density_of_mercury = RubyUnits::Unit.new(
|
416
|
-
inhg.definition = RubyUnits::Unit.new(
|
419
|
+
RubyUnits::Unit.define("inHg") do |inhg|
|
420
|
+
density_of_mercury = RubyUnits::Unit.new("7653360911758079/562949953421312 g/cm^3") # 13.5951 g/cm^3 at 0 tempC
|
421
|
+
inhg.definition = RubyUnits::Unit.new("1 in") * RubyUnits::Unit.new("1 gee") * density_of_mercury
|
417
422
|
end
|
418
423
|
|
419
|
-
RubyUnits::Unit.define(
|
420
|
-
torr.definition = RubyUnits::Unit.new(
|
424
|
+
RubyUnits::Unit.define("torr") do |torr|
|
425
|
+
torr.definition = RubyUnits::Unit.new("1/760 atm")
|
421
426
|
torr.aliases = %w[Torr torr]
|
422
427
|
end
|
423
428
|
|
424
|
-
RubyUnits::Unit.define(
|
425
|
-
psi.definition = RubyUnits::Unit.new(
|
429
|
+
RubyUnits::Unit.define("psi") do |psi|
|
430
|
+
psi.definition = RubyUnits::Unit.new("1 lbf/in^2")
|
426
431
|
end
|
427
432
|
|
428
|
-
RubyUnits::Unit.define(
|
429
|
-
density_of_water = RubyUnits::Unit.new(
|
430
|
-
cmh2o.definition = RubyUnits::Unit.new(
|
433
|
+
RubyUnits::Unit.define("cmh2o") do |cmh2o|
|
434
|
+
density_of_water = RubyUnits::Unit.new("1 g/cm^3") # at 4 tempC
|
435
|
+
cmh2o.definition = RubyUnits::Unit.new("1 cm") * RubyUnits::Unit.new("1 gee") * density_of_water
|
431
436
|
cmh2o.aliases = %w[cmH2O cmh2o cmAq]
|
432
437
|
end
|
433
438
|
|
434
|
-
RubyUnits::Unit.define(
|
435
|
-
density_of_water = RubyUnits::Unit.new(
|
436
|
-
inh2o.definition = RubyUnits::Unit.new(
|
439
|
+
RubyUnits::Unit.define("inh2o") do |inh2o|
|
440
|
+
density_of_water = RubyUnits::Unit.new("1 g/cm^3") # at 4 tempC
|
441
|
+
inh2o.definition = RubyUnits::Unit.new("1 in") * RubyUnits::Unit.new("1 gee") * density_of_water
|
437
442
|
inh2o.aliases = %w[inH2O inh2o inAq]
|
438
443
|
end
|
439
444
|
|
440
445
|
# viscosity
|
441
446
|
|
442
|
-
RubyUnits::Unit.define(
|
443
|
-
poise.definition = RubyUnits::Unit.new(
|
447
|
+
RubyUnits::Unit.define("poise") do |poise|
|
448
|
+
poise.definition = RubyUnits::Unit.new("dPa*s")
|
444
449
|
poise.aliases = %w[P poise]
|
445
450
|
end
|
446
451
|
|
447
|
-
RubyUnits::Unit.define(
|
448
|
-
stokes.definition = RubyUnits::Unit.new(
|
452
|
+
RubyUnits::Unit.define("stokes") do |stokes|
|
453
|
+
stokes.definition = RubyUnits::Unit.new("1 cm^2/s")
|
449
454
|
stokes.aliases = %w[St stokes]
|
450
455
|
end
|
451
456
|
|
452
457
|
# #energy
|
453
458
|
|
454
|
-
RubyUnits::Unit.define(
|
455
|
-
joule.definition = RubyUnits::Unit.new(
|
459
|
+
RubyUnits::Unit.define("joule") do |joule|
|
460
|
+
joule.definition = RubyUnits::Unit.new("1 N*m")
|
456
461
|
joule.aliases = %w[J joule joules]
|
457
462
|
end
|
458
463
|
|
459
|
-
RubyUnits::Unit.define(
|
460
|
-
erg.definition = RubyUnits::Unit.new(
|
464
|
+
RubyUnits::Unit.define("erg") do |erg|
|
465
|
+
erg.definition = RubyUnits::Unit.new("1 g*cm^2/s^2")
|
461
466
|
erg.aliases = %w[erg ergs]
|
462
467
|
end
|
463
468
|
|
464
469
|
# power
|
465
470
|
|
466
|
-
RubyUnits::Unit.define(
|
467
|
-
watt.definition = RubyUnits::Unit.new(
|
471
|
+
RubyUnits::Unit.define("watt") do |watt|
|
472
|
+
watt.definition = RubyUnits::Unit.new("1 N*m/s")
|
468
473
|
watt.aliases = %w[W Watt watt watts]
|
469
474
|
end
|
470
475
|
|
471
|
-
RubyUnits::Unit.define(
|
472
|
-
hp.definition = RubyUnits::Unit.new(
|
476
|
+
RubyUnits::Unit.define("horsepower") do |hp|
|
477
|
+
hp.definition = RubyUnits::Unit.new("33000 ft*lbf/min")
|
473
478
|
hp.aliases = %w[hp horsepower]
|
474
479
|
end
|
475
480
|
|
476
481
|
# energy
|
477
|
-
RubyUnits::Unit.define(
|
478
|
-
btu.definition = RubyUnits::Unit.new(
|
482
|
+
RubyUnits::Unit.define("btu") do |btu|
|
483
|
+
btu.definition = RubyUnits::Unit.new("2320092679909671/2199023255552 J") # 1055.056 J --- ISO standard
|
479
484
|
btu.aliases = %w[Btu btu Btus btus]
|
480
485
|
end
|
481
486
|
|
482
|
-
RubyUnits::Unit.define(
|
483
|
-
therm.definition = RubyUnits::Unit.new(
|
487
|
+
RubyUnits::Unit.define("therm") do |therm|
|
488
|
+
therm.definition = RubyUnits::Unit.new("100 kBtu")
|
484
489
|
therm.aliases = %w[thm therm therms Therm]
|
485
490
|
end
|
486
491
|
|
487
492
|
# "small" calorie
|
488
|
-
RubyUnits::Unit.define(
|
489
|
-
calorie.definition = RubyUnits::Unit.new(
|
493
|
+
RubyUnits::Unit.define("calorie") do |calorie|
|
494
|
+
calorie.definition = RubyUnits::Unit.new("4.184 J")
|
490
495
|
calorie.aliases = %w[cal calorie calories]
|
491
496
|
end
|
492
497
|
|
493
498
|
# "big" calorie
|
494
|
-
RubyUnits::Unit.define(
|
495
|
-
calorie.definition = RubyUnits::Unit.new(
|
499
|
+
RubyUnits::Unit.define("Calorie") do |calorie|
|
500
|
+
calorie.definition = RubyUnits::Unit.new("1 kcal")
|
496
501
|
calorie.aliases = %w[Cal Calorie Calories]
|
497
502
|
end
|
498
503
|
|
499
|
-
RubyUnits::Unit.define(
|
500
|
-
molar.definition = RubyUnits::Unit.new(
|
504
|
+
RubyUnits::Unit.define("molar") do |molar|
|
505
|
+
molar.definition = RubyUnits::Unit.new("1 mole/l")
|
501
506
|
molar.aliases = %w[M molar]
|
502
507
|
end
|
503
508
|
|
504
509
|
# potential
|
505
|
-
RubyUnits::Unit.define(
|
506
|
-
volt.definition = RubyUnits::Unit.new(
|
510
|
+
RubyUnits::Unit.define("volt") do |volt|
|
511
|
+
volt.definition = RubyUnits::Unit.new("1 W/A")
|
507
512
|
volt.aliases = %w[V volt volts]
|
508
513
|
end
|
509
514
|
|
510
515
|
# capacitance
|
511
|
-
RubyUnits::Unit.define(
|
512
|
-
farad.definition = RubyUnits::Unit.new(
|
516
|
+
RubyUnits::Unit.define("farad") do |farad|
|
517
|
+
farad.definition = RubyUnits::Unit.new("1 A*s/V")
|
513
518
|
farad.aliases = %w[F farad farads]
|
514
519
|
end
|
515
520
|
|
516
521
|
# charge
|
517
|
-
RubyUnits::Unit.define(
|
518
|
-
coulomb.definition = RubyUnits::Unit.new(
|
522
|
+
RubyUnits::Unit.define("coulomb") do |coulomb|
|
523
|
+
coulomb.definition = RubyUnits::Unit.new("1 A*s")
|
519
524
|
coulomb.aliases = %w[C coulomb coulombs]
|
520
525
|
end
|
521
526
|
|
522
527
|
# conductance
|
523
|
-
RubyUnits::Unit.define(
|
524
|
-
siemens.definition = RubyUnits::Unit.new(
|
528
|
+
RubyUnits::Unit.define("siemens") do |siemens|
|
529
|
+
siemens.definition = RubyUnits::Unit.new("1 A/V")
|
525
530
|
siemens.aliases = %w[S siemens]
|
526
531
|
end
|
527
532
|
|
528
533
|
# inductance
|
529
|
-
RubyUnits::Unit.define(
|
530
|
-
henry.definition = RubyUnits::Unit.new(
|
534
|
+
RubyUnits::Unit.define("henry") do |henry|
|
535
|
+
henry.definition = RubyUnits::Unit.new("1 J/A^2")
|
531
536
|
henry.aliases = %w[H henry henries]
|
532
537
|
end
|
533
538
|
|
534
539
|
# resistance
|
535
|
-
RubyUnits::Unit.define(
|
536
|
-
ohm.definition = RubyUnits::Unit.new(
|
540
|
+
RubyUnits::Unit.define("ohm") do |ohm|
|
541
|
+
ohm.definition = RubyUnits::Unit.new("1 V/A")
|
537
542
|
ohm.aliases = %w[Ohm ohm ohms]
|
538
543
|
end
|
539
544
|
|
540
545
|
# magnetism
|
541
546
|
|
542
|
-
RubyUnits::Unit.define(
|
543
|
-
weber.definition = RubyUnits::Unit.new(
|
547
|
+
RubyUnits::Unit.define("weber") do |weber|
|
548
|
+
weber.definition = RubyUnits::Unit.new("1 V*s")
|
544
549
|
weber.aliases = %w[Wb weber webers]
|
545
550
|
end
|
546
551
|
|
547
|
-
RubyUnits::Unit.define(
|
548
|
-
tesla.definition = RubyUnits::Unit.new(
|
552
|
+
RubyUnits::Unit.define("tesla") do |tesla|
|
553
|
+
tesla.definition = RubyUnits::Unit.new("1 V*s/m^2")
|
549
554
|
tesla.aliases = %w[T tesla teslas]
|
550
555
|
end
|
551
556
|
|
552
|
-
RubyUnits::Unit.define(
|
553
|
-
gauss.definition = RubyUnits::Unit.new(
|
557
|
+
RubyUnits::Unit.define("gauss") do |gauss|
|
558
|
+
gauss.definition = RubyUnits::Unit.new("100 microT")
|
554
559
|
gauss.aliases = %w[G gauss]
|
555
560
|
end
|
556
561
|
|
557
|
-
RubyUnits::Unit.define(
|
558
|
-
maxwell.definition = RubyUnits::Unit.new(
|
562
|
+
RubyUnits::Unit.define("maxwell") do |maxwell|
|
563
|
+
maxwell.definition = RubyUnits::Unit.new("1 gauss*cm^2")
|
559
564
|
maxwell.aliases = %w[Mx maxwell maxwells]
|
560
565
|
end
|
561
566
|
|
562
|
-
RubyUnits::Unit.define(
|
563
|
-
oersted.definition = RubyUnits::Unit.new(250.0 / Math::PI,
|
567
|
+
RubyUnits::Unit.define("oersted") do |oersted|
|
568
|
+
oersted.definition = RubyUnits::Unit.new(250.0 / Math::PI, "A/m")
|
564
569
|
oersted.aliases = %w[Oe oersted oersteds]
|
565
570
|
end
|
566
571
|
|
567
572
|
# activity
|
568
|
-
RubyUnits::Unit.define(
|
569
|
-
katal.definition = RubyUnits::Unit.new(
|
573
|
+
RubyUnits::Unit.define("katal") do |katal|
|
574
|
+
katal.definition = RubyUnits::Unit.new("1 mole/sec")
|
570
575
|
katal.aliases = %w[kat katal]
|
571
576
|
end
|
572
577
|
|
573
|
-
RubyUnits::Unit.define(
|
574
|
-
unit.definition = RubyUnits::Unit.new(
|
578
|
+
RubyUnits::Unit.define("unit") do |unit|
|
579
|
+
unit.definition = RubyUnits::Unit.new("1/60 microkatal")
|
575
580
|
unit.aliases = %w[U enzUnit units]
|
576
581
|
end
|
577
582
|
|
578
583
|
# frequency
|
579
584
|
|
580
|
-
RubyUnits::Unit.define(
|
581
|
-
hz.definition = RubyUnits::Unit.new(
|
585
|
+
RubyUnits::Unit.define("hertz") do |hz|
|
586
|
+
hz.definition = RubyUnits::Unit.new("1 1/s")
|
582
587
|
hz.aliases = %w[Hz hertz]
|
583
588
|
end
|
584
589
|
|
585
590
|
# angle
|
586
|
-
RubyUnits::Unit.define(
|
587
|
-
deg.definition = RubyUnits::Unit.new(Math::PI / 180.0,
|
591
|
+
RubyUnits::Unit.define("degree") do |deg|
|
592
|
+
deg.definition = RubyUnits::Unit.new(Math::PI / 180.0, "radian")
|
588
593
|
deg.aliases = %w[deg degree degrees]
|
589
594
|
end
|
590
595
|
|
591
|
-
RubyUnits::Unit.define(
|
592
|
-
grad.definition = RubyUnits::Unit.new(Math::PI / 200.0,
|
596
|
+
RubyUnits::Unit.define("gon") do |grad|
|
597
|
+
grad.definition = RubyUnits::Unit.new(Math::PI / 200.0, "radian")
|
593
598
|
grad.aliases = %w[gon grad gradian grads]
|
594
599
|
end
|
595
600
|
|
596
601
|
# rotation
|
597
|
-
RubyUnits::Unit.define(
|
598
|
-
rotation.definition = RubyUnits::Unit.new(2.0 * Math::PI,
|
602
|
+
RubyUnits::Unit.define("rotation") do |rotation|
|
603
|
+
rotation.definition = RubyUnits::Unit.new(2.0 * Math::PI, "radian")
|
599
604
|
end
|
600
605
|
|
601
|
-
RubyUnits::Unit.define(
|
602
|
-
rpm.definition = RubyUnits::Unit.new(
|
606
|
+
RubyUnits::Unit.define("rpm") do |rpm|
|
607
|
+
rpm.definition = RubyUnits::Unit.new("1 rotation/min")
|
603
608
|
end
|
604
609
|
|
605
610
|
# memory
|
606
|
-
RubyUnits::Unit.define(
|
607
|
-
bit.definition = RubyUnits::Unit.new(
|
611
|
+
RubyUnits::Unit.define("bit") do |bit|
|
612
|
+
bit.definition = RubyUnits::Unit.new("1/8 byte")
|
608
613
|
bit.aliases = %w[b bit]
|
609
614
|
end
|
610
615
|
|
611
616
|
# currency
|
612
|
-
RubyUnits::Unit.define(
|
613
|
-
cents.definition = RubyUnits::Unit.new(
|
617
|
+
RubyUnits::Unit.define("cents") do |cents|
|
618
|
+
cents.definition = RubyUnits::Unit.new("1/100 dollar")
|
614
619
|
end
|
615
620
|
|
616
621
|
# luminosity
|
617
|
-
RubyUnits::Unit.define(
|
618
|
-
lumen.definition = RubyUnits::Unit.new(
|
622
|
+
RubyUnits::Unit.define("lumen") do |lumen|
|
623
|
+
lumen.definition = RubyUnits::Unit.new("1 cd*steradian")
|
619
624
|
lumen.aliases = %w[lm lumen]
|
620
625
|
end
|
621
626
|
|
622
|
-
RubyUnits::Unit.define(
|
623
|
-
lux.definition = RubyUnits::Unit.new(
|
627
|
+
RubyUnits::Unit.define("lux") do |lux|
|
628
|
+
lux.definition = RubyUnits::Unit.new("1 lumen/m^2")
|
624
629
|
end
|
625
630
|
|
626
631
|
# radiation
|
627
|
-
RubyUnits::Unit.define(
|
628
|
-
gray.definition = RubyUnits::Unit.new(
|
632
|
+
RubyUnits::Unit.define("gray") do |gray|
|
633
|
+
gray.definition = RubyUnits::Unit.new("1 J/kg")
|
629
634
|
gray.aliases = %w[Gy gray grays]
|
630
635
|
end
|
631
636
|
|
632
|
-
RubyUnits::Unit.define(
|
633
|
-
roentgen.definition = RubyUnits::Unit.new(
|
637
|
+
RubyUnits::Unit.define("roentgen") do |roentgen|
|
638
|
+
roentgen.definition = RubyUnits::Unit.new("2.58e-4 C/kg")
|
634
639
|
roentgen.aliases = %w[R roentgen]
|
635
640
|
end
|
636
641
|
|
637
|
-
RubyUnits::Unit.define(
|
638
|
-
sievert.definition = RubyUnits::Unit.new(
|
642
|
+
RubyUnits::Unit.define("sievert") do |sievert|
|
643
|
+
sievert.definition = RubyUnits::Unit.new("1 J/kg")
|
639
644
|
sievert.aliases = %w[Sv sievert sieverts]
|
640
645
|
end
|
641
646
|
|
642
|
-
RubyUnits::Unit.define(
|
643
|
-
becquerel.definition = RubyUnits::Unit.new(
|
647
|
+
RubyUnits::Unit.define("becquerel") do |becquerel|
|
648
|
+
becquerel.definition = RubyUnits::Unit.new("1 1/s")
|
644
649
|
becquerel.aliases = %w[Bq becquerel becquerels]
|
645
650
|
end
|
646
651
|
|
647
|
-
RubyUnits::Unit.define(
|
648
|
-
curie.definition = RubyUnits::Unit.new(
|
652
|
+
RubyUnits::Unit.define("curie") do |curie|
|
653
|
+
curie.definition = RubyUnits::Unit.new("37 GBq")
|
649
654
|
curie.aliases = %w[Ci curie curies]
|
650
655
|
end
|
651
656
|
|
652
|
-
RubyUnits::Unit.define(
|
653
|
-
count.definition = RubyUnits::Unit.new(
|
657
|
+
RubyUnits::Unit.define("count") do |count|
|
658
|
+
count.definition = RubyUnits::Unit.new("1 each")
|
654
659
|
count.kind = :counting
|
655
660
|
end
|
656
661
|
|
657
662
|
# rate
|
658
|
-
RubyUnits::Unit.define(
|
659
|
-
cpm.definition = RubyUnits::Unit.new(
|
663
|
+
RubyUnits::Unit.define("cpm") do |cpm|
|
664
|
+
cpm.definition = RubyUnits::Unit.new("1 count/min")
|
660
665
|
end
|
661
666
|
|
662
|
-
RubyUnits::Unit.define(
|
663
|
-
dpm.definition = RubyUnits::Unit.new(
|
667
|
+
RubyUnits::Unit.define("dpm") do |dpm|
|
668
|
+
dpm.definition = RubyUnits::Unit.new("1 count/min")
|
664
669
|
end
|
665
670
|
|
666
|
-
RubyUnits::Unit.define(
|
667
|
-
bpm.definition = RubyUnits::Unit.new(
|
671
|
+
RubyUnits::Unit.define("bpm") do |bpm|
|
672
|
+
bpm.definition = RubyUnits::Unit.new("1 count/min")
|
668
673
|
end
|
669
674
|
|
670
675
|
# misc
|
671
|
-
RubyUnits::Unit.define(
|
672
|
-
dozen.definition = RubyUnits::Unit.new(
|
676
|
+
RubyUnits::Unit.define("dozen") do |dozen|
|
677
|
+
dozen.definition = RubyUnits::Unit.new("12 each")
|
673
678
|
dozen.aliases = %w[doz dz dozen]
|
674
679
|
dozen.kind = :counting
|
675
680
|
end
|
676
681
|
|
677
|
-
RubyUnits::Unit.define(
|
678
|
-
gross.definition = RubyUnits::Unit.new(
|
682
|
+
RubyUnits::Unit.define("gross") do |gross|
|
683
|
+
gross.definition = RubyUnits::Unit.new("12 dozen")
|
679
684
|
gross.aliases = %w[gr gross]
|
680
685
|
gross.kind = :counting
|
681
686
|
end
|
682
687
|
|
683
|
-
RubyUnits::Unit.define(
|
684
|
-
cell.definition = RubyUnits::Unit.new(
|
688
|
+
RubyUnits::Unit.define("cell") do |cell|
|
689
|
+
cell.definition = RubyUnits::Unit.new("1 each")
|
685
690
|
cell.aliases = %w[cells cell]
|
686
691
|
cell.kind = :counting
|
687
692
|
end
|
688
693
|
|
689
|
-
RubyUnits::Unit.define(
|
690
|
-
bp.definition = RubyUnits::Unit.new(
|
694
|
+
RubyUnits::Unit.define("base-pair") do |bp|
|
695
|
+
bp.definition = RubyUnits::Unit.new("1 each")
|
691
696
|
bp.aliases = %w[bp base-pair]
|
692
697
|
bp.kind = :counting
|
693
698
|
end
|
694
699
|
|
695
|
-
RubyUnits::Unit.define(
|
696
|
-
nt.definition = RubyUnits::Unit.new(
|
700
|
+
RubyUnits::Unit.define("nucleotide") do |nt|
|
701
|
+
nt.definition = RubyUnits::Unit.new("1 each")
|
697
702
|
nt.aliases = %w[nt]
|
698
703
|
nt.kind = :counting
|
699
704
|
end
|
700
705
|
|
701
|
-
RubyUnits::Unit.define(
|
702
|
-
molecule.definition = RubyUnits::Unit.new(
|
706
|
+
RubyUnits::Unit.define("molecule") do |molecule|
|
707
|
+
molecule.definition = RubyUnits::Unit.new("1 each")
|
703
708
|
molecule.aliases = %w[molecule molecules]
|
704
709
|
molecule.kind = :counting
|
705
710
|
end
|
706
711
|
|
707
|
-
RubyUnits::Unit.define(
|
708
|
-
percent.definition = RubyUnits::Unit.new(
|
712
|
+
RubyUnits::Unit.define("percent") do |percent|
|
713
|
+
percent.definition = RubyUnits::Unit.new("1/100")
|
709
714
|
percent.aliases = %w[% percent]
|
710
715
|
end
|
711
716
|
|
712
|
-
RubyUnits::Unit.define(
|
717
|
+
RubyUnits::Unit.define("ppm") do |ppm|
|
713
718
|
ppm.definition = RubyUnits::Unit.new(1) / 1_000_000
|
714
719
|
end
|
715
720
|
|
716
|
-
RubyUnits::Unit.define(
|
721
|
+
RubyUnits::Unit.define("ppb") do |ppb|
|
717
722
|
ppb.definition = RubyUnits::Unit.new(1) / 1_000_000_000
|
718
723
|
end
|