ruby-units 1.4.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.txt +45 -44
- data/README.md +190 -129
- data/Rakefile.rb +13 -77
- data/VERSION +1 -1
- data/lib/ruby-units.rb +0 -6
- data/lib/ruby_units/array.rb +1 -3
- data/lib/ruby_units/date.rb +30 -32
- data/lib/ruby_units/definition.rb +13 -13
- data/lib/ruby_units/namespaced.rb +0 -1
- data/lib/ruby_units/numeric.rb +0 -2
- data/lib/ruby_units/string.rb +11 -18
- data/lib/ruby_units/time.rb +10 -12
- data/lib/ruby_units/unit.rb +102 -137
- data/lib/ruby_units/unit_definitions/prefix.rb +30 -30
- data/lib/ruby_units/unit_definitions/standard.rb +11 -1
- data/ruby-units.gemspec +9 -14
- metadata +6 -29
- data/TODO +0 -3
- data/lib/ruby_units.rb +0 -9
- data/lib/ruby_units/fixnum.rb +0 -22
- data/lib/ruby_units/object.rb +0 -15
@@ -1,35 +1,35 @@
|
|
1
1
|
|
2
2
|
{
|
3
|
-
'googol' => [%w{googol},
|
4
|
-
'
|
5
|
-
'zebi' => [%w{Zi Zebi zebi},
|
6
|
-
'
|
7
|
-
'pebi' => [%w{Pi Pebi pebi},
|
8
|
-
'tebi' => [%w{Ti Tebi tebi},
|
9
|
-
'gibi' => [%w{Gi Gibi gibi},
|
10
|
-
'mebi' => [%w{Mi Mebi mebi},
|
11
|
-
'kibi' => [%w{Ki Kibi kibi},
|
12
|
-
'yotta' => [%w{Y Yotta yotta},
|
13
|
-
'zetta' => [%w{Z Zetta zetta},
|
14
|
-
'exa' => [%w{E Exa exa},
|
15
|
-
'peta' => [%w{P Peta peta},
|
16
|
-
'tera' => [%w{T Tera tera},
|
17
|
-
'giga' => [%w{G Giga giga},
|
18
|
-
'mega' => [%w{M Mega mega},
|
19
|
-
'kilo' => [%w{k kilo},
|
20
|
-
'hecto' => [%w{h Hecto hecto},
|
21
|
-
'deca' => [%w{da Deca deca deka},
|
22
|
-
'1' => [%w{1},
|
23
|
-
'deci' => [%w{d Deci deci},
|
24
|
-
'centi' => [%w{c Centi centi},
|
25
|
-
'milli' => [%w{m Milli milli},
|
26
|
-
'micro' => [%w{u Micro micro mc},
|
27
|
-
'nano' => [%w{n Nano nano},
|
28
|
-
'pico' => [%w{p Pico pico},
|
29
|
-
'femto' => [%w{f Femto femto},
|
30
|
-
'atto' => [%w{a Atto atto},
|
31
|
-
'zepto' => [%w{z Zepto zepto},
|
32
|
-
'yocto' => [%w{y Yocto yocto},
|
3
|
+
'googol' => [%w{googol}, 1e100],
|
4
|
+
'yobi' => [%w{Yi Yobi yobi}, 2**80],
|
5
|
+
'zebi' => [%w{Zi Zebi zebi}, 2**70],
|
6
|
+
'exbi' => [%w{Ei Exbi exbi}, 2**60],
|
7
|
+
'pebi' => [%w{Pi Pebi pebi}, 2**50],
|
8
|
+
'tebi' => [%w{Ti Tebi tebi}, 2**40],
|
9
|
+
'gibi' => [%w{Gi Gibi gibi}, 2**30],
|
10
|
+
'mebi' => [%w{Mi Mebi mebi}, 2**20],
|
11
|
+
'kibi' => [%w{Ki Kibi kibi}, 2**10],
|
12
|
+
'yotta' => [%w{Y Yotta yotta}, 1e24],
|
13
|
+
'zetta' => [%w{Z Zetta zetta}, 1e21],
|
14
|
+
'exa' => [%w{E Exa exa}, 1e18],
|
15
|
+
'peta' => [%w{P Peta peta}, 1e15],
|
16
|
+
'tera' => [%w{T Tera tera}, 1e12],
|
17
|
+
'giga' => [%w{G Giga giga}, 1e9],
|
18
|
+
'mega' => [%w{M Mega mega}, 1e6],
|
19
|
+
'kilo' => [%w{k kilo}, 1e3],
|
20
|
+
'hecto' => [%w{h Hecto hecto}, 1e2],
|
21
|
+
'deca' => [%w{da Deca deca deka}, 1e1],
|
22
|
+
'1' => [%w{1}, 1],
|
23
|
+
'deci' => [%w{d Deci deci}, Rational(1,1e1)],
|
24
|
+
'centi' => [%w{c Centi centi}, Rational(1,1e2)],
|
25
|
+
'milli' => [%w{m Milli milli}, Rational(1,1e3)],
|
26
|
+
'micro' => [%w{u µ Micro micro mc}, Rational(1,1e6)],
|
27
|
+
'nano' => [%w{n Nano nano}, Rational(1,1e9)],
|
28
|
+
'pico' => [%w{p Pico pico}, Rational(1,1e12)],
|
29
|
+
'femto' => [%w{f Femto femto}, Rational(1,1e15)],
|
30
|
+
'atto' => [%w{a Atto atto}, Rational(1,1e18)],
|
31
|
+
'zepto' => [%w{z Zepto zepto}, Rational(1,1e21)],
|
32
|
+
'yocto' => [%w{y Yocto yocto}, Rational(1,1e24)]
|
33
33
|
}.each do |name, definition|
|
34
34
|
RubyUnits::Unit.define(name) do |unit|
|
35
35
|
aliases, scalar = definition
|
@@ -104,7 +104,7 @@ end
|
|
104
104
|
avagadro_constant = RubyUnits::Unit.new('6.02214129e23 1/mol')
|
105
105
|
|
106
106
|
RubyUnits::Unit.define('AMU') do |amu|
|
107
|
-
amu.definition = RubyUnits::Unit.new('
|
107
|
+
amu.definition = RubyUnits::Unit.new('0.012 kg/mol') / (12 * avagadro_constant)
|
108
108
|
amu.aliases = %w{u AMU amu}
|
109
109
|
end
|
110
110
|
|
@@ -250,6 +250,16 @@ RubyUnits::Unit.define('teaspoon') do |tsp|
|
|
250
250
|
tsp.aliases = %w{tsp teaspoon teaspoons}
|
251
251
|
end
|
252
252
|
|
253
|
+
##
|
254
|
+
# The board-foot is a specialized unit of measure for the volume of lumber in
|
255
|
+
# the United States and Canada. It is the volume of a one-foot length of a board
|
256
|
+
# one foot wide and one inch thick.
|
257
|
+
# http://en.wikipedia.org/wiki/Board_foot
|
258
|
+
RubyUnits::Unit.define('bdft') do |bdft|
|
259
|
+
bdft.definition = RubyUnits::Unit.new('1/12 ft^3')
|
260
|
+
bdft.aliases = %w{fbm boardfoot boardfeet bf}
|
261
|
+
end
|
262
|
+
|
253
263
|
# volumetric flow
|
254
264
|
|
255
265
|
RubyUnits::Unit.define('cfm') do |cfm|
|
data/ruby-units.gemspec
CHANGED
@@ -2,41 +2,37 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile.rb, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: ruby-units
|
5
|
+
# stub: ruby-units 2.0.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "ruby-units"
|
9
|
-
s.version = "
|
9
|
+
s.version = "2.0.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Kevin Olbrich, Ph.D."]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2015-11-09"
|
15
15
|
s.description = "Provides classes and methods to perform unit math and conversions"
|
16
16
|
s.email = ["kevin.olbrich+ruby_units@gmail.com"]
|
17
17
|
s.extra_rdoc_files = [
|
18
|
+
"CHANGELOG.txt",
|
18
19
|
"LICENSE.txt",
|
19
|
-
"README.md"
|
20
|
-
"TODO"
|
20
|
+
"README.md"
|
21
21
|
]
|
22
22
|
s.files = [
|
23
23
|
"CHANGELOG.txt",
|
24
24
|
"LICENSE.txt",
|
25
25
|
"README.md",
|
26
26
|
"Rakefile.rb",
|
27
|
-
"TODO",
|
28
27
|
"VERSION",
|
29
28
|
"lib/ruby-units.rb",
|
30
|
-
"lib/ruby_units.rb",
|
31
29
|
"lib/ruby_units/array.rb",
|
32
30
|
"lib/ruby_units/cache.rb",
|
33
31
|
"lib/ruby_units/date.rb",
|
34
32
|
"lib/ruby_units/definition.rb",
|
35
|
-
"lib/ruby_units/fixnum.rb",
|
36
33
|
"lib/ruby_units/math.rb",
|
37
34
|
"lib/ruby_units/namespaced.rb",
|
38
35
|
"lib/ruby_units/numeric.rb",
|
39
|
-
"lib/ruby_units/object.rb",
|
40
36
|
"lib/ruby_units/string.rb",
|
41
37
|
"lib/ruby_units/time.rb",
|
42
38
|
"lib/ruby_units/unit.rb",
|
@@ -49,8 +45,7 @@ Gem::Specification.new do |s|
|
|
49
45
|
]
|
50
46
|
s.homepage = "https://github.com/olbrich/ruby-units"
|
51
47
|
s.licenses = ["MIT"]
|
52
|
-
s.
|
53
|
-
s.rubygems_version = "2.2.2"
|
48
|
+
s.rubygems_version = "2.5.0"
|
54
49
|
s.summary = "A class that performs unit conversions and unit math"
|
55
50
|
|
56
51
|
if s.respond_to? :specification_version then
|
@@ -59,16 +54,16 @@ Gem::Specification.new do |s|
|
|
59
54
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
55
|
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
61
56
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
62
|
-
s.add_development_dependency(%q<pry>, [">= 0"])
|
57
|
+
s.add_development_dependency(%q<pry-byebug>, [">= 0"])
|
63
58
|
else
|
64
59
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
65
60
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
66
|
-
s.add_dependency(%q<pry>, [">= 0"])
|
61
|
+
s.add_dependency(%q<pry-byebug>, [">= 0"])
|
67
62
|
end
|
68
63
|
else
|
69
64
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
70
65
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
71
|
-
s.add_dependency(%q<pry>, [">= 0"])
|
66
|
+
s.add_dependency(%q<pry-byebug>, [">= 0"])
|
72
67
|
end
|
73
68
|
end
|
74
69
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-units
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Olbrich, Ph.D.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: pry
|
42
|
+
name: pry-byebug
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -58,27 +58,23 @@ email:
|
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files:
|
61
|
+
- CHANGELOG.txt
|
61
62
|
- LICENSE.txt
|
62
63
|
- README.md
|
63
|
-
- TODO
|
64
64
|
files:
|
65
65
|
- CHANGELOG.txt
|
66
66
|
- LICENSE.txt
|
67
67
|
- README.md
|
68
68
|
- Rakefile.rb
|
69
|
-
- TODO
|
70
69
|
- VERSION
|
71
70
|
- lib/ruby-units.rb
|
72
|
-
- lib/ruby_units.rb
|
73
71
|
- lib/ruby_units/array.rb
|
74
72
|
- lib/ruby_units/cache.rb
|
75
73
|
- lib/ruby_units/date.rb
|
76
74
|
- lib/ruby_units/definition.rb
|
77
|
-
- lib/ruby_units/fixnum.rb
|
78
75
|
- lib/ruby_units/math.rb
|
79
76
|
- lib/ruby_units/namespaced.rb
|
80
77
|
- lib/ruby_units/numeric.rb
|
81
|
-
- lib/ruby_units/object.rb
|
82
78
|
- lib/ruby_units/string.rb
|
83
79
|
- lib/ruby_units/time.rb
|
84
80
|
- lib/ruby_units/unit.rb
|
@@ -92,26 +88,7 @@ homepage: https://github.com/olbrich/ruby-units
|
|
92
88
|
licenses:
|
93
89
|
- MIT
|
94
90
|
metadata: {}
|
95
|
-
post_install_message:
|
96
|
-
====================
|
97
|
-
Deprecation Warning
|
98
|
-
====================
|
99
|
-
|
100
|
-
Several convenience methods that ruby-units added to the string class have
|
101
|
-
been deprecated in this release. These methods include String#to, String#from, String#ago, String#before and others.
|
102
|
-
If your code relies on these functions, they can be added back by adding this line to your code.
|
103
|
-
|
104
|
-
require 'ruby-units/string/extras'
|
105
|
-
# note that these methods do not play well with Rails, which is one of the reasons they are being removed.
|
106
|
-
|
107
|
-
The extra functions mostly work the same, but will no longer properly handle cases when they are called with strings..
|
108
|
-
|
109
|
-
'min'.from("4-1-2011") # => Exception
|
110
|
-
|
111
|
-
Pass in a Date, Time, or DateTime object to get the expected result.
|
112
|
-
|
113
|
-
They will go away completely in the next release, so it would be a good idea to refactor your code
|
114
|
-
to avoid using them. They will also throw deprecation warnings when they are used.
|
91
|
+
post_install_message:
|
115
92
|
rdoc_options: []
|
116
93
|
require_paths:
|
117
94
|
- lib
|
@@ -127,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
104
|
version: '0'
|
128
105
|
requirements: []
|
129
106
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.5.0
|
131
108
|
signing_key:
|
132
109
|
specification_version: 4
|
133
110
|
summary: A class that performs unit conversions and unit math
|
data/TODO
DELETED
data/lib/ruby_units.rb
DELETED
data/lib/ruby_units/fixnum.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
if RUBY_VERSION < "1.9"
|
2
|
-
# :nocov_19:
|
3
|
-
class Fixnum
|
4
|
-
alias quo_without_units quo
|
5
|
-
|
6
|
-
# @note this patch is necessary for ruby 1.8 because cases where Integers are divided by Units don't work quite right
|
7
|
-
# @param [Numeric]
|
8
|
-
# @return [Unit, Integer]
|
9
|
-
def quo_with_units(other)
|
10
|
-
case other
|
11
|
-
when RubyUnits::Unit
|
12
|
-
self * other.inverse
|
13
|
-
else
|
14
|
-
quo_without_units(other)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
alias quo quo_with_units
|
19
|
-
alias / quo_with_units
|
20
|
-
end
|
21
|
-
# :nocov_19:
|
22
|
-
end
|
data/lib/ruby_units/object.rb
DELETED