units 1.0.0 → 1.0.1
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.
- data/README +5 -5
- data/Rakefile +1 -1
- data/lib/units/standard.rb +31 -24
- metadata +2 -2
data/README
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
==Welcome to Units
|
2
2
|
|
3
|
-
This is a package for people
|
3
|
+
This is a package for people who want units with their numbers. For all of the conversions provided in units/standard, please see Numeric.
|
4
4
|
|
5
5
|
== Download
|
6
6
|
|
@@ -16,7 +16,7 @@ This is a package for people that want units for their numbers. For all of the c
|
|
16
16
|
1.euro.usd # => 1.2545
|
17
17
|
|
18
18
|
1.usd.unit # => :usd
|
19
|
-
1.usd.to_yen # => 108.9 # this information is grabbed on the fly
|
19
|
+
1.usd.to_yen # => 108.9 # this information is grabbed on the fly via a SOAP call
|
20
20
|
1.usd.to_yet.unit # => :yen
|
21
21
|
|
22
22
|
==Comparing Units with Rails' ActiveSupport
|
@@ -34,9 +34,9 @@ This is a package for people that want units for their numbers. For all of the c
|
|
34
34
|
1.hour.unit # => :hours
|
35
35
|
1.hour.to_i # => 3600
|
36
36
|
1.hour.to_seconds # => 3600
|
37
|
-
1.hour.
|
38
|
-
1.hour.
|
39
|
-
1.foot.
|
37
|
+
1.hour.to_minutes # => 60
|
38
|
+
1.hour.to_hours # => 1 <-- this makes sense, there is 1 hour in an hour
|
39
|
+
1.foot.to_inches # => 12
|
40
40
|
|
41
41
|
== How to Write Your Own Conversions
|
42
42
|
class Numeric
|
data/Rakefile
CHANGED
data/lib/units/standard.rb
CHANGED
@@ -14,29 +14,26 @@ class Numeric
|
|
14
14
|
:grams => [ :gm, :gms, :gram ]
|
15
15
|
}
|
16
16
|
VOLUME = {
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:teaspoons => 768,
|
38
|
-
:fluid_drams => 1024,
|
39
|
-
:minims => 61440
|
17
|
+
:pints => 0.125,
|
18
|
+
:milliliters => 0.000264172051,
|
19
|
+
:cubic_feet => 7.48051945,
|
20
|
+
:cups => 0.0625,
|
21
|
+
:microliters => 2.64172051,
|
22
|
+
:cubic_inches => 0.00432900431,
|
23
|
+
:liters => 0.264172051,
|
24
|
+
:cubic_centimeters => 0.000264172051,
|
25
|
+
:cubic_yards => 201.974025,
|
26
|
+
:hectoliters => 26.4172051,
|
27
|
+
:fluid_ounces => 0.0078125,
|
28
|
+
:cubic_millimeters => 2.64172051,
|
29
|
+
:gallons => 1,
|
30
|
+
:deciliters => 0.0264172051,
|
31
|
+
:tablespoons => 0.00390625,
|
32
|
+
:cubic_meters => 264.172051,
|
33
|
+
:quarts => 0.25,
|
34
|
+
:centiliters => 0.00264172051,
|
35
|
+
:teaspoons => 0.00130208333,
|
36
|
+
:cubic_decimeters => 0.264172051
|
40
37
|
}
|
41
38
|
VOLUME_ALIASES = {
|
42
39
|
:liters => [ :liter, :l ],
|
@@ -141,7 +138,17 @@ class Float #:nodoc:
|
|
141
138
|
when :time
|
142
139
|
to_seconds._to_i
|
143
140
|
when :size
|
144
|
-
|
141
|
+
to_bytes._to_i
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
alias :_to_int :to_int
|
146
|
+
def to_int
|
147
|
+
case kind
|
148
|
+
when :time
|
149
|
+
to_seconds._to_int
|
150
|
+
when :size
|
151
|
+
to_bytes._to_int
|
145
152
|
end
|
146
153
|
end
|
147
154
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: units
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2005-09-
|
6
|
+
version: 1.0.1
|
7
|
+
date: 2005-09-06
|
8
8
|
summary: A general way to add units and conversion ability to numbers in Ruby.
|
9
9
|
require_paths:
|
10
10
|
- lib
|