units 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +5 -5
  2. data/Rakefile +1 -1
  3. data/lib/units/standard.rb +31 -24
  4. metadata +2 -2
data/README CHANGED
@@ -1,6 +1,6 @@
1
1
  ==Welcome to Units
2
2
 
3
- This is a package for people that want units for their numbers. For all of the conversions provided in units/standard, please see Numeric.
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.minutes # => 60
38
- 1.hour.hour # => 1 <-- this makes sense, there is 1 hour in an hour
39
- 1.foot.inches # => 12
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
@@ -5,7 +5,7 @@ require 'rake/rdoctask'
5
5
  require 'rake/gempackagetask'
6
6
  require 'rake/contrib/rubyforgepublisher'
7
7
 
8
- PKG_VERSION = "1.0.0"
8
+ PKG_VERSION = "1.0.1"
9
9
 
10
10
  PKG_FILES = FileList[
11
11
  "lib/**/*", "bin/*", "test/**/*", "[A-Z]*", "Rakefile", "doc/**/*"
@@ -14,29 +14,26 @@ class Numeric
14
14
  :grams => [ :gm, :gms, :gram ]
15
15
  }
16
16
  VOLUME = {
17
- :liters => 0.00492892161,
18
- :hectoliters => 0.0000492892161,
19
- :deciliters => 0.0492892161,
20
- :centiliters => 0.492892161,
21
- :milliliters => 4.92892161,
22
- :microliters => 4928.92161,
23
- :cubic_centimeters => 3785.4118,
24
- :cubic_millimeters => 3785411.8,
25
- :cubic_meters => 0.0037854118,
26
- :cubic_decimeters => 3.7854118,
27
- :cubic_feet => 0.133680556,
28
- :cubic_inches => 231.000001,
29
- :cubic_yards => 0.00495113171,
30
- :gallons => 1,
31
- :quarts => 4,
32
- :pints => 8,
33
- :cups => 16,
34
- :gills => 32,
35
- :fluid_ounces => 128,
36
- :tablespoons => 256,
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
- to_kilobytes._to_i
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.0
7
- date: 2005-09-05
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