ruby-units 4.0.3 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,98 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# seed the cache
|
2
|
-
RubyUnits::Unit.new(
|
4
|
+
RubyUnits::Unit.new("1")
|
3
5
|
|
4
|
-
RubyUnits::Unit.define(
|
6
|
+
RubyUnits::Unit.define("meter") do |unit|
|
5
7
|
unit.scalar = 1
|
6
8
|
unit.numerator = %w[<meter>]
|
7
9
|
unit.aliases = %w[m meter meters metre metres]
|
8
10
|
unit.kind = :length
|
9
11
|
end
|
10
12
|
|
11
|
-
RubyUnits::Unit.define(
|
13
|
+
RubyUnits::Unit.define("kilogram") do |unit|
|
12
14
|
unit.scalar = 1
|
13
15
|
unit.numerator = %w[<kilogram>]
|
14
16
|
unit.aliases = %w[kg kilogram kilograms]
|
15
17
|
unit.kind = :mass
|
16
18
|
end
|
17
19
|
|
18
|
-
RubyUnits::Unit.define(
|
20
|
+
RubyUnits::Unit.define("second") do |unit|
|
19
21
|
unit.scalar = 1
|
20
22
|
unit.numerator = %w[<second>]
|
21
23
|
unit.aliases = %w[s sec second seconds]
|
22
24
|
unit.kind = :time
|
23
25
|
end
|
24
26
|
|
25
|
-
RubyUnits::Unit.define(
|
27
|
+
RubyUnits::Unit.define("mole") do |unit|
|
26
28
|
unit.scalar = 1
|
27
29
|
unit.numerator = %w[<mole>]
|
28
30
|
unit.aliases = %w[mol mole]
|
29
31
|
unit.kind = :substance
|
30
32
|
end
|
31
33
|
|
32
|
-
RubyUnits::Unit.define(
|
34
|
+
RubyUnits::Unit.define("ampere") do |unit|
|
33
35
|
unit.scalar = 1
|
34
36
|
unit.numerator = %w[<ampere>]
|
35
37
|
unit.aliases = %w[A ampere amperes amp amps]
|
36
38
|
unit.kind = :current
|
37
39
|
end
|
38
40
|
|
39
|
-
RubyUnits::Unit.define(
|
41
|
+
RubyUnits::Unit.define("radian") do |unit|
|
40
42
|
unit.scalar = 1
|
41
43
|
unit.numerator = %w[<radian>]
|
42
44
|
unit.aliases = %w[rad radian radians]
|
43
45
|
unit.kind = :angle
|
44
46
|
end
|
45
47
|
|
46
|
-
RubyUnits::Unit.define(
|
48
|
+
RubyUnits::Unit.define("kelvin") do |unit|
|
47
49
|
unit.scalar = 1
|
48
50
|
unit.numerator = %w[<kelvin>]
|
49
51
|
unit.aliases = %w[degK kelvin]
|
50
52
|
unit.kind = :temperature
|
51
53
|
end
|
52
54
|
|
53
|
-
RubyUnits::Unit.define(
|
55
|
+
RubyUnits::Unit.define("tempK") do |unit|
|
54
56
|
unit.scalar = 1
|
55
57
|
unit.numerator = %w[<tempK>]
|
56
58
|
unit.aliases = %w[tempK]
|
57
59
|
unit.kind = :temperature
|
58
60
|
end
|
59
61
|
|
60
|
-
RubyUnits::Unit.define(
|
62
|
+
RubyUnits::Unit.define("byte") do |unit|
|
61
63
|
unit.scalar = 1
|
62
64
|
unit.numerator = %w[<byte>]
|
63
65
|
unit.aliases = %w[B byte bytes]
|
64
66
|
unit.kind = :information
|
65
67
|
end
|
66
68
|
|
67
|
-
RubyUnits::Unit.define(
|
69
|
+
RubyUnits::Unit.define("dollar") do |unit|
|
68
70
|
unit.scalar = 1
|
69
71
|
unit.numerator = %w[<dollar>]
|
70
72
|
unit.aliases = %w[USD dollar]
|
71
73
|
unit.kind = :currency
|
72
74
|
end
|
73
75
|
|
74
|
-
RubyUnits::Unit.define(
|
76
|
+
RubyUnits::Unit.define("candela") do |unit|
|
75
77
|
unit.scalar = 1
|
76
78
|
unit.numerator = %w[<candela>]
|
77
79
|
unit.aliases = %w[cd candela]
|
78
80
|
unit.kind = :luminosity
|
79
81
|
end
|
80
82
|
|
81
|
-
RubyUnits::Unit.define(
|
83
|
+
RubyUnits::Unit.define("each") do |unit|
|
82
84
|
unit.scalar = 1
|
83
85
|
unit.numerator = %w[<each>]
|
84
86
|
unit.aliases = %w[each]
|
85
87
|
unit.kind = :counting
|
86
88
|
end
|
87
89
|
|
88
|
-
RubyUnits::Unit.define(
|
90
|
+
RubyUnits::Unit.define("steradian") do |unit|
|
89
91
|
unit.scalar = 1
|
90
92
|
unit.numerator = %w[<steradian>]
|
91
93
|
unit.aliases = %w[sr steradian steradians]
|
92
94
|
unit.kind = :solid_angle
|
93
95
|
end
|
94
96
|
|
95
|
-
RubyUnits::Unit.define(
|
97
|
+
RubyUnits::Unit.define("decibel") do |unit|
|
96
98
|
unit.scalar = 1
|
97
99
|
unit.numerator = %w[<decibel>]
|
98
100
|
unit.aliases = %w[dB decibel decibels]
|
@@ -1,34 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
4
|
+
"googol" => [%w[googol], 1e100],
|
5
|
+
"yobi" => [%w[Yi Yobi yobi], 2**80],
|
6
|
+
"zebi" => [%w[Zi Zebi zebi], 2**70],
|
7
|
+
"exbi" => [%w[Ei Exbi exbi], 2**60],
|
8
|
+
"pebi" => [%w[Pi Pebi pebi], 2**50],
|
9
|
+
"tebi" => [%w[Ti Tebi tebi], 2**40],
|
10
|
+
"gibi" => [%w[Gi Gibi gibi], 2**30],
|
11
|
+
"mebi" => [%w[Mi Mebi mebi], 2**20],
|
12
|
+
"kibi" => [%w[Ki Kibi kibi], 2**10],
|
13
|
+
"yotta" => [%w[Y Yotta yotta], 1e24],
|
14
|
+
"zetta" => [%w[Z Zetta zetta], 1e21],
|
15
|
+
"exa" => [%w[E Exa exa], 1e18],
|
16
|
+
"peta" => [%w[P Peta peta], 1e15],
|
17
|
+
"tera" => [%w[T Tera tera], 1e12],
|
18
|
+
"giga" => [%w[G Giga giga], 1e9],
|
19
|
+
"mega" => [%w[M Mega mega], 1e6],
|
20
|
+
"kilo" => [%w[k kilo], 1e3],
|
21
|
+
"hecto" => [%w[h Hecto hecto], 1e2],
|
22
|
+
"deca" => [%w[da Deca deca deka], 1e1],
|
23
|
+
"1" => [%w[1], 1],
|
24
|
+
"deci" => [%w[d Deci deci], Rational(1, 1e1)],
|
25
|
+
"centi" => [%w[c Centi centi], Rational(1, 1e2)],
|
26
|
+
"milli" => [%w[m Milli milli], Rational(1, 1e3)],
|
27
|
+
"micro" => [%w[u µ Micro micro mc], Rational(1, 1e6)],
|
28
|
+
"nano" => [%w[n Nano nano], Rational(1, 1e9)],
|
29
|
+
"pico" => [%w[p Pico pico], Rational(1, 1e12)],
|
30
|
+
"femto" => [%w[f Femto femto], Rational(1, 1e15)],
|
31
|
+
"atto" => [%w[a Atto atto], Rational(1, 1e18)],
|
32
|
+
"zepto" => [%w[z Zepto zepto], Rational(1, 1e21)],
|
33
|
+
"yocto" => [%w[y Yocto yocto], Rational(1, 1e24)]
|
32
34
|
}.each do |name, definition|
|
33
35
|
RubyUnits::Unit.define(name) do |unit|
|
34
36
|
aliases, scalar = definition
|