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