ruby-units 4.0.2 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,98 +1,100 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # seed the cache
2
- RubyUnits::Unit.new('1')
4
+ RubyUnits::Unit.new("1")
3
5
 
4
- RubyUnits::Unit.define('meter') do |unit|
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('kilogram') do |unit|
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('second') do |unit|
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('mole') do |unit|
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('ampere') do |unit|
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('radian') do |unit|
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('kelvin') do |unit|
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('tempK') do |unit|
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('byte') do |unit|
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('dollar') do |unit|
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('candela') do |unit|
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('each') do |unit|
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('steradian') do |unit|
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('decibel') do |unit|
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
- 'googol' => [%w[googol], 1e100],
3
- 'yobi' => [%w[Yi Yobi yobi], 2**80],
4
- 'zebi' => [%w[Zi Zebi zebi], 2**70],
5
- 'exbi' => [%w[Ei Exbi exbi], 2**60],
6
- 'pebi' => [%w[Pi Pebi pebi], 2**50],
7
- 'tebi' => [%w[Ti Tebi tebi], 2**40],
8
- 'gibi' => [%w[Gi Gibi gibi], 2**30],
9
- 'mebi' => [%w[Mi Mebi mebi], 2**20],
10
- 'kibi' => [%w[Ki Kibi kibi], 2**10],
11
- 'yotta' => [%w[Y Yotta yotta], 1e24],
12
- 'zetta' => [%w[Z Zetta zetta], 1e21],
13
- 'exa' => [%w[E Exa exa], 1e18],
14
- 'peta' => [%w[P Peta peta], 1e15],
15
- 'tera' => [%w[T Tera tera], 1e12],
16
- 'giga' => [%w[G Giga giga], 1e9],
17
- 'mega' => [%w[M Mega mega], 1e6],
18
- 'kilo' => [%w[k kilo], 1e3],
19
- 'hecto' => [%w[h Hecto hecto], 1e2],
20
- 'deca' => [%w[da Deca deca deka], 1e1],
21
- '1' => [%w[1], 1],
22
- 'deci' => [%w[d Deci deci], Rational(1, 1e1)],
23
- 'centi' => [%w[c Centi centi], Rational(1, 1e2)],
24
- 'milli' => [%w[m Milli milli], Rational(1, 1e3)],
25
- 'micro' => [%w[u µ Micro micro mc], Rational(1, 1e6)],
26
- 'nano' => [%w[n Nano nano], Rational(1, 1e9)],
27
- 'pico' => [%w[p Pico pico], Rational(1, 1e12)],
28
- 'femto' => [%w[f Femto femto], Rational(1, 1e15)],
29
- 'atto' => [%w[a Atto atto], Rational(1, 1e18)],
30
- 'zepto' => [%w[z Zepto zepto], Rational(1, 1e21)],
31
- 'yocto' => [%w[y Yocto yocto], Rational(1, 1e24)]
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