ruby-units 1.3.0.a → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,248 @@
1
+ class Unit < Numeric
2
+ UNIT_DEFINITIONS = {
3
+ # prefixes
4
+ '<googol>' => [%w{googol}, 1e100, :prefix],
5
+ '<kibi>' => [%w{Ki Kibi kibi}, 2**10, :prefix],
6
+ '<mebi>' => [%w{Mi Mebi mebi}, 2**20, :prefix],
7
+ '<gibi>' => [%w{Gi Gibi gibi}, 2**30, :prefix],
8
+ '<tebi>' => [%w{Ti Tebi tebi}, 2**40, :prefix],
9
+ '<pebi>' => [%w{Pi Pebi pebi}, 2**50, :prefix],
10
+ '<exi>' => [%w{Ei Exi exi}, 2**60, :prefix],
11
+ '<zebi>' => [%w{Zi Zebi zebi}, 2**70, :prefix],
12
+ '<yebi>' => [%w{Yi Yebi yebi}, 2**80, :prefix],
13
+ '<yotta>' => [%w{Y Yotta yotta}, 1e24, :prefix],
14
+ '<zetta>' => [%w{Z Zetta zetta}, 1e21, :prefix],
15
+ '<exa>' => [%w{E Exa exa}, 1e18, :prefix],
16
+ '<peta>' => [%w{P Peta peta}, 1e15, :prefix],
17
+ '<tera>' => [%w{T Tera tera}, 1e12, :prefix],
18
+ '<giga>' => [%w{G Giga giga}, 1e9, :prefix],
19
+ '<mega>' => [%w{M Mega mega}, 1e6, :prefix],
20
+ '<kilo>' => [%w{k kilo}, 1e3, :prefix],
21
+ '<hecto>' => [%w{h Hecto hecto}, 1e2, :prefix],
22
+ '<deca>' => [%w{da Deca deca deka}, 1e1, :prefix],
23
+ '<deci>' => [%w{d Deci deci}, Rational(1,1e1), :prefix],
24
+ '<centi>' => [%w{c Centi centi}, Rational(1,1e2), :prefix],
25
+ '<milli>' => [%w{m Milli milli}, Rational(1,1e3), :prefix],
26
+ '<micro>' => [%w{u Micro micro}, Rational(1,1e6), :prefix],
27
+ '<nano>' => [%w{n Nano nano}, Rational(1,1e9), :prefix],
28
+ '<pico>' => [%w{p Pico pico}, Rational(1,1e12), :prefix],
29
+ '<femto>' => [%w{f Femto femto}, Rational(1,1e15), :prefix],
30
+ '<atto>' => [%w{a Atto atto}, Rational(1,1e18), :prefix],
31
+ '<zepto>' => [%w{z Zepto zepto}, Rational(1,1e21), :prefix],
32
+ '<yocto>' => [%w{y Yocto yocto}, Rational(1,1e24), :prefix],
33
+ '<1>' => [%w{1},1,:prefix],
34
+
35
+ # length units
36
+ '<meter>' => [%w{m meter meters metre metres}, 1, :length, %w{<meter>} ],
37
+ '<inch>' => [%w{in inch inches "}, Rational(254,10_000), :length, %w{<meter>}],
38
+ '<foot>' => [%w{ft foot feet '}, Rational(3048,10_000), :length, %w{<meter>}],
39
+ '<yard>' => [%w{yd yard yards}, 0.9144, :length, %w{<meter>}],
40
+ '<mile>' => [%w{mi mile miles}, 1609.344, :length, %w{<meter>}],
41
+ '<naut-mile>' => [%w{nmi}, 1852, :length, %w{<meter>}],
42
+ '<league>'=> [%w{league leagues}, 4828, :length, %w{<meter>}],
43
+ '<furlong>'=> [%w{furlong furlongs}, 201.2, :length, %w{<meter>}],
44
+ '<rod>' => [%w{rd rod rods}, 5.029, :length, %w{<meter>}],
45
+ '<mil>' => [%w{mil mils}, 0.0000254, :length, %w{<meter>}],
46
+ '<angstrom>' =>[%w{ang angstrom angstroms}, Rational(1,1e10), :length, %w{<meter>}],
47
+ '<fathom>' => [%w{fathom fathoms}, 1.829, :length, %w{<meter>}],
48
+ '<pica>' => [%w{pica picas}, 0.004217, :length, %w{<meter>}],
49
+ '<point>' => [%w{pt point points}, 0.0003514, :length, %w{<meter>}],
50
+ '<redshift>' => [%w{z red-shift}, 1.302773e26, :length, %w{<meter>}],
51
+ '<AU>' => [%w{AU astronomical-unit}, 149597900000, :length, %w{<meter>}],
52
+ '<light-second>'=>[%w{ls light-second}, 299792500, :length, %w{<meter>}],
53
+ '<light-minute>'=>[%w{lmin light-minute}, 17987550000, :length, %w{<meter>}],
54
+ '<light-year>' => [%w{ly light-year}, 9460528000000000, :length, %w{<meter>}],
55
+ '<parsec>' => [%w{pc parsec parsecs}, 30856780000000000, :length, %w{<meter>}],
56
+
57
+ #mass
58
+ '<kilogram>' => [%w{kg kilogram kilograms}, 1, :mass, %w{<kilogram>}],
59
+ '<AMU>' => [%w{u AMU amu}, 6.0221415e26, :mass, %w{<kilogram>}],
60
+ '<dalton>' => [%w{Da Dalton Daltons dalton daltons}, 6.0221415e26, :mass, %w{<kilogram>}],
61
+ '<slug>' => [%w{slug slugs}, 14.5939029, :mass, %w{<kilogram>}],
62
+ '<short-ton>' => [%w{tn ton}, 907.18474, :mass, %w{<kilogram>}],
63
+ '<metric-ton>'=>[%w{tonne}, 1000, :mass, %w{<kilogram>}],
64
+ '<carat>' => [%w{ct carat carats}, 0.0002, :mass, %w{<kilogram>}],
65
+ '<pound>' => [%w{lbs lb pound pounds #}, Rational(8171193714040401,18014398509481984), :mass, %w{<kilogram>}],
66
+ '<ounce>' => [%w{oz ounce ounces}, Rational(8171193714040401,288230376151711744), :mass, %w{<kilogram>}],
67
+ '<gram>' => [%w{g gram grams gramme grammes},Rational(1,1e3),:mass, %w{<kilogram>}],
68
+
69
+ #area
70
+ '<hectare>'=>[%w{hectare}, 10000, :area, %w{<meter> <meter>}],
71
+ '<acre>'=>[%w(acre acres), 4046.85642, :area, %w{<meter> <meter>}],
72
+ '<sqft>'=>[%w(sqft), 1, :area, %w{<feet> <feet>}],
73
+
74
+ #volume
75
+ '<liter>' => [%w{l L liter liters litre litres}, Rational(1,1e3), :volume, %w{<meter> <meter> <meter>}],
76
+ '<gallon>'=> [%w{gal gallon gallons}, 0.0037854118, :volume, %w{<meter> <meter> <meter>}],
77
+ '<quart>'=> [%w{qt quart quarts}, 0.00094635295, :volume, %w{<meter> <meter> <meter>}],
78
+ '<pint>'=> [%w{pt pint pints}, 0.000473176475, :volume, %w{<meter> <meter> <meter>}],
79
+ '<cup>'=> [%w{cu cup cups}, 0.000236588238, :volume, %w{<meter> <meter> <meter>}],
80
+ '<fluid-ounce>'=> [%w{floz fluid-ounce}, 2.95735297e-5, :volume, %w{<meter> <meter> <meter>}],
81
+ '<tablespoon>'=> [%w{tbs tablespoon tablespoons}, 1.47867648e-5, :volume, %w{<meter> <meter> <meter>}],
82
+ '<teaspoon>'=> [%w{tsp teaspoon teaspoons}, 4.92892161e-6, :volume, %w{<meter> <meter> <meter>}],
83
+
84
+ #speed
85
+ '<kph>' => [%w{kph}, 0.277777778, :speed, %w{<meter>}, %w{<second>}],
86
+ '<mph>' => [%w{mph}, 0.44704, :speed, %w{<meter>}, %w{<second>}],
87
+ '<knot>' => [%w{kt kn kts knot knots}, 0.514444444, :speed, %w{<meter>}, %w{<second>}],
88
+ '<fps>' => [%w{fps}, 0.3048, :speed, %w{<meter>}, %w{<second>}],
89
+
90
+ #acceleration
91
+ '<gee>' => [%w{gee}, 9.80655, :acceleration, %w{<meter>}, %w{<second> <second>}],
92
+
93
+ #temperature_difference
94
+ '<kelvin>' => [%w{degK kelvin}, 1, :temperature, %w{<kelvin>}],
95
+ '<celsius>' => [%w{degC celsius celsius centigrade}, 1, :temperature, %w{<kelvin>}],
96
+ '<fahrenheit>' => [%w{degF fahrenheit}, Rational(1,1.8), :temperature, %w{<kelvin>}],
97
+ '<rankine>' => [%w{degR rankine}, Rational(1,1.8), :temperature, %w{<kelvin>}],
98
+ '<temp-K>' => [%w{tempK}, 1, :temperature, %w{<temp-K>}],
99
+ '<temp-C>' => [%w{tempC}, 1, :temperature, %w{<temp-K>}],
100
+ '<temp-F>' => [%w{tempF}, Rational(1,1.8), :temperature, %w{<temp-K>}],
101
+ '<temp-R>' => [%w{tempR}, Rational(1,1.8), :temperature, %w{<temp-K>}],
102
+
103
+ #time
104
+ '<second>'=> [%w{s sec second seconds}, 1, :time, %w{<second>}],
105
+ '<minute>'=> [%w{min minute minutes}, 60, :time, %w{<second>}],
106
+ '<hour>'=> [%w{h hr hrs hour hours}, 3600, :time, %w{<second>}],
107
+ '<day>'=> [%w{d day days}, 3600*24, :time, %w{<second>}],
108
+ '<week>'=> [%w{wk week weeks}, 7*3600*24, :time, %w{<second>}],
109
+ '<fortnight>'=> [%w{fortnight fortnights}, 1209600, :time, %W{<second>}],
110
+ '<year>'=> [%w{y yr year years annum}, 31556926, :time, %w{<second>}],
111
+ '<decade>'=>[%w{decade decades}, 315569260, :time, %w{<second>}],
112
+ '<century>'=>[%w{century centuries}, 3155692600, :time, %w{<second>}],
113
+
114
+ #pressure
115
+ '<pascal>' => [%w{Pa pascal Pascal}, 1, :pressure, %w{<kilogram>},%w{<meter> <second> <second>}],
116
+ '<bar>' => [%w{bar bars}, 100000, :pressure, %w{<kilogram>},%w{<meter> <second> <second>}],
117
+ '<mmHg>' => [%w{mmHg}, 133.322368,:pressure, %w{<kilogram>},%w{<meter> <second> <second>}],
118
+ '<inHg>' => [%w{inHg}, 3386.3881472,:pressure, %w{<kilogram>},%w{<meter> <second> <second>}],
119
+ '<torr>' => [%w{torr}, 133.322368,:pressure, %w{<kilogram>},%w{<meter> <second> <second>}],
120
+ '<bar>' => [%w{bar}, 100000,:pressure, %w{<kilogram>},%w{<meter> <second> <second>}],
121
+ '<atm>' => [%w{atm ATM atmosphere atmospheres}, 101325,:pressure, %w{<kilogram>},%w{<meter> <second> <second>}],
122
+ '<psi>' => [%w{psi}, 6894.76,:pressure, %w{<kilogram>},%w{<meter> <second> <second>}],
123
+ '<cmh2o>' => [%w{cmH2O}, 98.0638,:pressure, %w{<kilogram>},%w{<meter> <second> <second>}],
124
+ '<inh2o>' => [%w{inH2O}, 249.082052,:pressure, %w{<kilogram>},%w{<meter> <second> <second>}],
125
+
126
+ #viscosity
127
+ '<poise>' => [%w{P poise}, Rational(1,10), :viscosity, %w{<kilogram>},%w{<meter> <second>} ],
128
+ '<stokes>' => [%w{St stokes}, Rational(1,1e4), :viscosity, %w{<meter> <meter>}, %w{<second>}],
129
+
130
+ #substance
131
+ '<mole>' => [%w{mol mole}, 1, :substance, %w{<mole>}],
132
+
133
+ #concentration
134
+ '<molar>' => [%w{M molar}, 1000, :concentration, %w{<mole>}, %w{<meter> <meter> <meter>}],
135
+ '<wtpercent>' => [%w{wt% wtpercent}, 10, :concentration, %w{<kilogram>}, %w{<meter> <meter> <meter>}],
136
+
137
+ #activity
138
+ '<katal>' => [%w{kat katal Katal}, 1, :activity, %w{<mole>}, %w{<second>}],
139
+ '<unit>' => [%w{U enzUnit}, 16.667e-16, :activity, %w{<mole>}, %w{<second>}],
140
+
141
+ #capacitance
142
+ '<farad>' => [%w{F farad Farad}, 1, :capacitance, %w{<farad>}],
143
+
144
+ #charge
145
+ '<coulomb>' => [%w{C coulomb Coulomb}, 1, :charge, %w{<ampere> <second>}],
146
+
147
+ #current
148
+ '<ampere>' => [%w{A Ampere ampere amp amps}, 1, :current, %w{<ampere>}],
149
+
150
+ #conductance
151
+ '<siemens>' => [%w{S Siemens siemens}, 1, :resistance, %w{<second> <second> <second> <ampere> <ampere>}, %w{<kilogram> <meter> <meter>}],
152
+
153
+ #inductance
154
+ '<henry>' => [%w{H Henry henry}, 1, :inductance, %w{<meter> <meter> <kilogram>}, %w{<second> <second> <ampere> <ampere>}],
155
+
156
+ #potential
157
+ '<volt>' => [%w{V Volt volt volts}, 1, :potential, %w{<meter> <meter> <kilogram>}, %w{<second> <second> <second> <ampere>}],
158
+
159
+ #resistance
160
+ '<ohm>' => [%w{Ohm ohm}, 1, :resistance, %w{<meter> <meter> <kilogram>},%w{<second> <second> <second> <ampere> <ampere>}],
161
+
162
+ #magnetism
163
+ '<weber>' => [%w{Wb weber webers}, 1, :magnetism, %w{<meter> <meter> <kilogram>}, %w{<second> <second> <ampere>}],
164
+ '<tesla>' => [%w{T tesla teslas}, 1, :magnetism, %w{<kilogram>}, %w{<second> <second> <ampere>}],
165
+ '<gauss>' => [%w{G gauss}, Rational(1,1e4), :magnetism, %w{<kilogram>}, %w{<second> <second> <ampere>}],
166
+ '<maxwell>' => [%w{Mx maxwell maxwells}, Rational(1,1e8), :magnetism, %w{<meter> <meter> <kilogram>}, %w{<second> <second> <ampere>}],
167
+ '<oersted>' => [%w{Oe oersted oersteds}, 250.0/Math::PI, :magnetism, %w{<ampere>}, %w{<meter>}],
168
+
169
+ #energy
170
+ '<joule>' => [%w{J joule Joule joules}, 1, :energy, %w{<meter> <meter> <kilogram>}, %w{<second> <second>}],
171
+ '<erg>' => [%w{erg ergs}, Rational(1,1e7), :energy, %w{<meter> <meter> <kilogram>}, %w{<second> <second>}],
172
+ '<btu>' => [%w{BTU btu BTUs}, 1055.056, :energy, %w{<meter> <meter> <kilogram>}, %w{<second> <second>}],
173
+ '<calorie>' => [%w{cal calorie calories}, 4.18400, :energy,%w{<meter> <meter> <kilogram>}, %w{<second> <second>}],
174
+ '<Calorie>' => [%w{Cal Calorie Calories}, 4184.00, :energy,%w{<meter> <meter> <kilogram>}, %w{<second> <second>}],
175
+ '<therm-US>' => [%w{th therm therms Therm}, 105480400, :energy,%w{<meter> <meter> <kilogram>}, %w{<second> <second>}],
176
+
177
+ #force
178
+ '<newton>' => [%w{N Newton newton}, 1, :force, %w{<kilogram> <meter>}, %w{<second> <second>}],
179
+ '<dyne>' => [%w{dyn dyne}, Rational(1,1e5), :force, %w{<kilogram> <meter>}, %w{<second> <second>}],
180
+ '<pound-force>' => [%w{lbf pound-force}, 4.448222, :force, %w{<kilogram> <meter>}, %w{<second> <second>}],
181
+
182
+ #frequency
183
+ '<hertz>' => [%w{Hz hertz Hertz}, 1, :frequency, %w{<1>}, %{<second>}],
184
+
185
+ #angle
186
+ '<radian>' =>[%w{rad radian radian radians}, 1, :angle, %w{<radian>}],
187
+ '<degree>' =>[%w{deg degree degrees}, Math::PI / 180.0, :angle, %w{<radian>}],
188
+ '<grad>' =>[%w{grad gradian grads}, Math::PI / 200.0, :angle, %w{<radian>}],
189
+ '<steradian>' => [%w{sr steradian steradians}, 1, :solid_angle, %w{<steradian>}],
190
+
191
+ #rotation
192
+ '<rotation>' => [%w{rotation}, 2.0*Math::PI, :angle, %w{<radian>}],
193
+ '<rpm>' =>[%w{rpm}, 2.0*Math::PI / 60.0, :angular_velocity, %w{<radian>}, %w{<second>}],
194
+
195
+ #memory
196
+ '<byte>' =>[%w{B byte}, 1, :memory, %w{<byte>}],
197
+ '<bit>' =>[%w{b bit}, 0.125, :memory, %w{<byte>}],
198
+
199
+ #currency
200
+ '<dollar>'=>[%w{USD dollar}, 1, :currency, %w{<dollar>}],
201
+ '<cents>' =>[%w{cents}, Rational(1,100), :currency, %w{<dollar>}],
202
+
203
+ #luminosity
204
+ '<candela>' => [%w{cd candela}, 1, :luminosity, %w{<candela>}],
205
+ '<lumen>' => [%w{lm lumen}, 1, :luminous_power, %w{<candela> <steradian>}],
206
+ '<lux>' =>[%w{lux}, 1, :illuminance, %w{<candela> <steradian>}, %w{<meter> <meter>}],
207
+
208
+ #power
209
+ '<watt>' => [%w{W watt watts}, 1, :power, %w{<kilogram> <meter> <meter>}, %w{<second> <second> <second>}],
210
+ '<horsepower>' => [%w{hp horsepower}, 745.699872, :power, %w{<kilogram> <meter> <meter>}, %w{<second> <second> <second>}],
211
+
212
+ #radiation
213
+ '<gray>' => [%w{Gy gray grays}, 1, :radiation, %w{<meter> <meter>}, %w{<second> <second>}],
214
+ '<roentgen>' => [%w{R roentgen}, 0.009330, :radiation, %w{<meter> <meter>}, %w{<second> <second>}],
215
+ '<sievert>' => [%w{Sv sievert sieverts}, 1, :radiation, %w{<meter> <meter>}, %w{<second> <second>}],
216
+ '<becquerel>' => [%w{Bq bequerel bequerels}, 1, :radiation, %w{<1>},%w{<second>}],
217
+ '<curie>' => [%w{Ci curie curies}, 3.7e10, :radiation, %w{<1>},%w{<second>}],
218
+
219
+ # rate
220
+ '<cpm>' => [%w{cpm}, Rational(1,60), :rate, %w{<count>},%w{<second>}],
221
+ '<dpm>' => [%w{dpm}, Rational(1,60), :rate, %w{<count>},%w{<second>}],
222
+ '<bpm>' => [%w{bpm}, Rational(1,60), :rate, %w{<count>},%w{<second>}],
223
+
224
+ #resolution / typography
225
+ '<dot>' => [%w{dot dots}, 1, :resolution, %w{<each>}],
226
+ '<pixel>' => [%w{pixel px}, 1, :resolution, %w{<each>}],
227
+ '<ppi>' => [%w{ppi}, 1, :resolution, %w{<pixel>}, %w{<inch>}],
228
+ '<dpi>' => [%w{dpi}, 1, :typography, %w{<dot>}, %w{<inch>}],
229
+ '<pica>' => [%w{pica}, 0.00423333333 , :typography, %w{<meter>}],
230
+ '<point>' => [%w{point pt}, 0.000352777778, :typography, %w{<meter>}],
231
+
232
+ #other
233
+ '<cell>' => [%w{cells cell}, 1, :counting, %w{<each>}],
234
+ '<each>' => [%w{each}, 1, :counting, %w{<each>}],
235
+ '<count>' => [%w{count}, 1, :counting, %w{<each>}],
236
+ '<base-pair>' => [%w{bp}, 1, :counting, %w{<each>}],
237
+ '<nucleotide>' => [%w{nt}, 1, :counting, %w{<each>}],
238
+ '<molecule>' => [%w{molecule molecules}, 1, :counting, %w{<1>}],
239
+ '<dozen>' => [%w{doz dz dozen},12,:prefix_only, %w{<each>}],
240
+ '<percent>'=> [%w{% percent}, Rational(1,100), :prefix_only, %w{<1>}],
241
+ '<ppm>' => [%w{ppm},Rational(1,1e6),:prefix_only, %w{<1>}],
242
+ '<ppt>' => [%w{ppt},Rational(1,1e9),:prefix_only, %w{<1>}],
243
+ '<gross>' => [%w{gr gross},144, :prefix_only, %w{<dozen> <dozen>}],
244
+ '<decibel>' => [%w{dB decibel decibels}, 1, :logarithmic, %w{<decibel>}]
245
+
246
+
247
+ } # doc
248
+ end
@@ -0,0 +1,5 @@
1
+ class Unit < Numeric
2
+ module Version
3
+ STRING = File.read(File.dirname(__FILE__) + "/../../VERSION")
4
+ end
5
+ end
@@ -0,0 +1,83 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in RakeFile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ruby-units}
8
+ s.version = "1.3.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kevin Olbrich, Ph.D."]
12
+ s.date = %q{2011-06-23}
13
+ s.description = %q{Provides classes and methods to perform unit math and conversions}
14
+ s.email = ["kevin.olbrich+ruby_units@gmail.com"]
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md",
18
+ "TODO"
19
+ ]
20
+ s.files = [
21
+ "CHANGELOG.txt",
22
+ "Gemfile",
23
+ "LICENSE.txt",
24
+ "Manifest.txt",
25
+ "README.md",
26
+ "RakeFile",
27
+ "TODO",
28
+ "VERSION",
29
+ "lib/ruby-units.rb",
30
+ "lib/ruby_units.rb",
31
+ "lib/ruby_units/array.rb",
32
+ "lib/ruby_units/cache.rb",
33
+ "lib/ruby_units/date.rb",
34
+ "lib/ruby_units/fixnum.rb",
35
+ "lib/ruby_units/math.rb",
36
+ "lib/ruby_units/numeric.rb",
37
+ "lib/ruby_units/object.rb",
38
+ "lib/ruby_units/string.rb",
39
+ "lib/ruby_units/time.rb",
40
+ "lib/ruby_units/unit.rb",
41
+ "lib/ruby_units/unit_definitions.rb",
42
+ "lib/ruby_units/version.rb",
43
+ "ruby-units.gemspec",
44
+ "spec/ruby-units/array_spec.rb",
45
+ "spec/ruby-units/complex_spec.rb",
46
+ "spec/ruby-units/date_spec.rb",
47
+ "spec/ruby-units/math_spec.rb",
48
+ "spec/ruby-units/numeric_spec.rb",
49
+ "spec/ruby-units/object_spec.rb",
50
+ "spec/ruby-units/string_spec.rb",
51
+ "spec/ruby-units/time_spec.rb",
52
+ "spec/ruby-units/unit_spec.rb",
53
+ "spec/spec_helper.rb",
54
+ "test/test_cache.rb",
55
+ "test/test_ruby-units.rb"
56
+ ]
57
+ s.homepage = %q{https://github.com/olbrich/ruby-units}
58
+ s.require_paths = ["lib"]
59
+ s.rubygems_version = %q{1.7.2}
60
+ s.summary = %q{A class that performs unit conversions and unit math}
61
+
62
+ if s.respond_to? :specification_version then
63
+ s.specification_version = 3
64
+
65
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
67
+ s.add_development_dependency(%q<rcov>, [">= 0"])
68
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
69
+ s.add_development_dependency(%q<rspec>, ["~> 2.5"])
70
+ else
71
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
72
+ s.add_dependency(%q<rcov>, [">= 0"])
73
+ s.add_dependency(%q<jeweler>, [">= 0"])
74
+ s.add_dependency(%q<rspec>, ["~> 2.5"])
75
+ end
76
+ else
77
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
78
+ s.add_dependency(%q<rcov>, [">= 0"])
79
+ s.add_dependency(%q<jeweler>, [">= 0"])
80
+ s.add_dependency(%q<rspec>, ["~> 2.5"])
81
+ end
82
+ end
83
+
@@ -45,11 +45,7 @@ describe String do
45
45
  specify { "now".to_datetime.should be_instance_of DateTime }
46
46
  specify { "now".to_time.should be_instance_of Time }
47
47
 
48
- if RUBY_VERSION < "1.9" && RUBY_PLATFORM != 'java'
49
- specify {"10001-01-01 12:00".time.should be_instance_of DateTime }
50
- else
51
- specify { "10001-01-01 12:00".time.should be_instance_of Time }
52
- end
48
+ specify { "10001-01-01 12:00".time.should be_instance_of Time }
53
49
  specify { "2001-01-01 12:00".time.should be_instance_of Time }
54
50
 
55
51
  end
@@ -852,4 +852,37 @@ describe "Unit Output formatting" do
852
852
  specify { expect {subject.to_s("random string")}.to raise_error(ArgumentError,"'random' Unit not recognized")}
853
853
  end
854
854
 
855
- end
855
+ end
856
+
857
+ describe "Foot-inch conversions" do
858
+ [
859
+ ["76 in", %Q{6'4"}],
860
+ ["77 in", %Q{6'5"}],
861
+ ["78 in", %Q{6'6"}],
862
+ ["79 in", %Q{6'7"}],
863
+ ["80 in", %Q{6'8"}],
864
+ ["87 in", %Q{7'3"}],
865
+ ["88 in", %Q{7'4"}],
866
+ ["89 in", %Q{7'5"}]
867
+ ].each do |inches, feet|
868
+ specify { Unit(inches).to("ft").should == Unit(feet)}
869
+ specify { Unit(inches).to_s(:ft).should == feet}
870
+ end
871
+ end
872
+
873
+ describe "pound-ounce conversions" do
874
+ [
875
+ ["76 oz", "4 lbs, 12 oz"],
876
+ ["77 oz", "4 lbs, 13 oz"],
877
+ ["78 oz", "4 lbs, 14 oz"],
878
+ ["79 oz", "4 lbs, 15 oz"],
879
+ ["80 oz", "5 lbs, 0 oz"],
880
+ ["87 oz", "5 lbs, 7 oz"],
881
+ ["88 oz", "5 lbs, 8 oz"],
882
+ ["89 oz", "5 lbs, 9 oz"]
883
+ ].each do |ounces, pounds|
884
+ specify { Unit(ounces).to("lbs").should == Unit(pounds)}
885
+ specify { Unit(ounces).to_s(:lbs).should == pounds}
886
+ end
887
+ end
888
+
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-units
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 6
5
- version: 1.3.0.a
4
+ prerelease:
5
+ version: 1.3.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kevin Olbrich, Ph.D.
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-30 00:00:00 Z
13
+ date: 2011-06-23 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -68,9 +68,29 @@ extra_rdoc_files:
68
68
  - README.md
69
69
  - TODO
70
70
  files:
71
+ - CHANGELOG.txt
72
+ - Gemfile
71
73
  - LICENSE.txt
74
+ - Manifest.txt
72
75
  - README.md
76
+ - RakeFile
73
77
  - TODO
78
+ - VERSION
79
+ - lib/ruby-units.rb
80
+ - lib/ruby_units.rb
81
+ - lib/ruby_units/array.rb
82
+ - lib/ruby_units/cache.rb
83
+ - lib/ruby_units/date.rb
84
+ - lib/ruby_units/fixnum.rb
85
+ - lib/ruby_units/math.rb
86
+ - lib/ruby_units/numeric.rb
87
+ - lib/ruby_units/object.rb
88
+ - lib/ruby_units/string.rb
89
+ - lib/ruby_units/time.rb
90
+ - lib/ruby_units/unit.rb
91
+ - lib/ruby_units/unit_definitions.rb
92
+ - lib/ruby_units/version.rb
93
+ - ruby-units.gemspec
74
94
  - spec/ruby-units/array_spec.rb
75
95
  - spec/ruby-units/complex_spec.rb
76
96
  - spec/ruby-units/date_spec.rb
@@ -100,9 +120,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
120
  required_rubygems_version: !ruby/object:Gem::Requirement
101
121
  none: false
102
122
  requirements:
103
- - - ">"
123
+ - - ">="
104
124
  - !ruby/object:Gem::Version
105
- version: 1.3.1
125
+ version: "0"
106
126
  requirements: []
107
127
 
108
128
  rubyforge_project:
@@ -110,16 +130,5 @@ rubygems_version: 1.7.2
110
130
  signing_key:
111
131
  specification_version: 3
112
132
  summary: A class that performs unit conversions and unit math
113
- test_files:
114
- - spec/ruby-units/array_spec.rb
115
- - spec/ruby-units/complex_spec.rb
116
- - spec/ruby-units/date_spec.rb
117
- - spec/ruby-units/math_spec.rb
118
- - spec/ruby-units/numeric_spec.rb
119
- - spec/ruby-units/object_spec.rb
120
- - spec/ruby-units/string_spec.rb
121
- - spec/ruby-units/time_spec.rb
122
- - spec/ruby-units/unit_spec.rb
123
- - spec/spec_helper.rb
124
- - test/test_cache.rb
125
- - test/test_ruby-units.rb
133
+ test_files: []
134
+