convert_unit 0.2.0 → 1.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.md +11 -0
- data/Gemfile.lock +1 -1
- data/README.md +7 -0
- data/lib/convert_unit.rb +7 -0
- data/lib/convert_unit/base.rb +24 -3
- data/lib/convert_unit/dynamic_viscosity.rb +26 -0
- data/lib/convert_unit/high_pressure.rb +26 -0
- data/lib/convert_unit/kinematic_viscosity.rb +26 -0
- data/lib/convert_unit/low_pressure.rb +26 -0
- data/lib/convert_unit/mass_flow.rb +26 -0
- data/lib/convert_unit/pre_process/dynamic_viscosity/conversion_rate.yml +12 -0
- data/lib/convert_unit/pre_process/dynamic_viscosity/process.rb +14 -0
- data/lib/convert_unit/pre_process/dynamic_viscosity/units.yml +3 -0
- data/lib/convert_unit/pre_process/dynamic_viscosity/units_symbol.yml +3 -0
- data/lib/convert_unit/pre_process/high_pressure/conversion_rate.yml +56 -0
- data/lib/convert_unit/pre_process/high_pressure/process.rb +14 -0
- data/lib/convert_unit/pre_process/high_pressure/units.yml +7 -0
- data/lib/convert_unit/pre_process/high_pressure/units_symbol.yml +7 -0
- data/lib/convert_unit/pre_process/kinematic_viscosity/conversion_rate.yml +20 -0
- data/lib/convert_unit/pre_process/kinematic_viscosity/process.rb +14 -0
- data/lib/convert_unit/pre_process/kinematic_viscosity/units.yml +4 -0
- data/lib/convert_unit/pre_process/kinematic_viscosity/units_symbol.yml +4 -0
- data/lib/convert_unit/pre_process/low_pressure/conversion_rate.yml +42 -0
- data/lib/convert_unit/pre_process/low_pressure/process.rb +14 -0
- data/lib/convert_unit/pre_process/low_pressure/units.yml +6 -0
- data/lib/convert_unit/pre_process/low_pressure/units_symbol.yml +6 -0
- data/lib/convert_unit/pre_process/mass_flow/conversion_rate.yml +20 -0
- data/lib/convert_unit/pre_process/mass_flow/process.rb +14 -0
- data/lib/convert_unit/pre_process/mass_flow/units.yml +4 -0
- data/lib/convert_unit/pre_process/mass_flow/units_symbol.yml +5 -0
- data/lib/convert_unit/pre_process/speed/conversion_rate.yml +42 -0
- data/lib/convert_unit/pre_process/speed/process.rb +14 -0
- data/lib/convert_unit/pre_process/speed/units.yml +6 -0
- data/lib/convert_unit/pre_process/speed/units_symbol.yml +6 -0
- data/lib/convert_unit/pre_process/torque/conversion_rate.yml +20 -0
- data/lib/convert_unit/pre_process/torque/process.rb +14 -0
- data/lib/convert_unit/pre_process/torque/units.yml +4 -0
- data/lib/convert_unit/pre_process/torque/units_symbol.yml +4 -0
- data/lib/convert_unit/speed.rb +26 -0
- data/lib/convert_unit/torque.rb +26 -0
- data/lib/convert_unit/version.rb +1 -1
- metadata +37 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aa8bca8706847e1e83544e1a58a19fbe9c36b0e
|
4
|
+
data.tar.gz: 4fef8f43c52b2a5139edc3e34e316c89a58af1f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e34734b62cc14064b7a6709922b702b7b7571641df3430addcab77bca052c8c31efdd61df9c23bac968b03215a8fd43a6d38792480f3a4f704219d05e9d50f5b
|
7
|
+
data.tar.gz: 64810872f381abf5c0bce5f473921419f899847f3a5a5d0688fe8191739df37fa4de8d3dd2ab015f56d881340286a50f863616a64147051f55e431bdb4520086
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## v1.0.0
|
2
|
+
* Stable Version
|
3
|
+
* Add MassFow
|
4
|
+
* Add HighPressure
|
5
|
+
* Add LowPressure
|
6
|
+
* Add KinematicViscosity
|
7
|
+
* Add Speed
|
8
|
+
* Add DynamicViscosity
|
9
|
+
* Add Torque
|
10
|
+
* Add formatter method to_c, to_s, to_i, to_r, to_f
|
11
|
+
|
1
12
|
## v0.2.0
|
2
13
|
* Change module required location
|
3
14
|
* Add module self method for get available unit conversion class
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -68,6 +68,13 @@ Volume | cm3, m3, ltr, in3, ft3, us_gal, imp_gal, us_brl
|
|
68
68
|
Density | g/ml kg/m3 lb/ft3 lb/in3
|
69
69
|
Volumetric Liquid flow | l/sec l/min m3 ft3/min ft3/hr gal/min brl/d
|
70
70
|
Volumetric Liquid flow | nm3/hr scfh scfm
|
71
|
+
Mass Flow | kg/h lb/h kg/s t/h
|
72
|
+
High Pressure | bar psi kpa mpa kgf/cm2 mm_hg atm
|
73
|
+
Low Pressure | mh2o fth2o cmhg inhg inh2o pa
|
74
|
+
KinematicViscosity | cs st ft2/s m2/s
|
75
|
+
Speed | m/s m/min km/h ft/s ft/min mi/h
|
76
|
+
DynamicViscosity | cp poise lb/ft·s
|
77
|
+
Torque | nm kgfm ftlb inlb
|
71
78
|
## Contributing
|
72
79
|
|
73
80
|
Bug reports and pull requests are welcome on GitHub at https://github.com/tanvir002700/convert_unit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/lib/convert_unit.rb
CHANGED
@@ -8,3 +8,10 @@ require 'convert_unit/volume'
|
|
8
8
|
require 'convert_unit/density'
|
9
9
|
require 'convert_unit/volumetric_liquid_flow'
|
10
10
|
require 'convert_unit/volumetric_gas_flow'
|
11
|
+
require 'convert_unit/mass_flow'
|
12
|
+
require 'convert_unit/high_pressure'
|
13
|
+
require 'convert_unit/low_pressure'
|
14
|
+
require 'convert_unit/kinematic_viscosity'
|
15
|
+
require 'convert_unit/speed'
|
16
|
+
require 'convert_unit/dynamic_viscosity'
|
17
|
+
require 'convert_unit/torque'
|
data/lib/convert_unit/base.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
class Base
|
2
|
+
require 'bigdecimal'
|
2
3
|
attr_accessor :value, :unit
|
3
4
|
|
4
|
-
def initialize(value, unit, valid_units)
|
5
|
+
def initialize(value, unit, valid_units, precision = 16)
|
5
6
|
raise TypeError, 'no implicit conversion of String into Integer' unless value.is_a? Numeric
|
6
7
|
raise TypeError, 'Invalid Unit Type' unless valid_units.include?(unit.to_s.downcase)
|
7
|
-
@value = value
|
8
|
+
@value = BigDecimal.new value, precision
|
8
9
|
@unit = unit.downcase
|
9
10
|
end
|
10
11
|
|
@@ -29,7 +30,27 @@ class Base
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def inspect
|
32
|
-
"#{
|
33
|
+
"#{value} #{unit}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_c
|
37
|
+
"#{value.to_c} #{unit}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_r;
|
41
|
+
"#{value.to_r} #{unit}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_f
|
45
|
+
"#{value.to_f} #{unit}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_i
|
49
|
+
"#{value.to_i} #{unit}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_s
|
53
|
+
"#{value.to_s} #{unit}"
|
33
54
|
end
|
34
55
|
|
35
56
|
protected
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'convert_unit/base'
|
2
|
+
require 'convert_unit/pre_process/dynamic_viscosity/process'
|
3
|
+
|
4
|
+
module ConvertUnit
|
5
|
+
class DynamicViscosity < Base
|
6
|
+
extend PreProcess::DynamicViscosity
|
7
|
+
UNITS_SYMBOL = load_units_symbol
|
8
|
+
UNITS = load_available_units
|
9
|
+
CONVERSION_RATE = load_conversion_rate
|
10
|
+
|
11
|
+
attr_accessor :value, :unit
|
12
|
+
|
13
|
+
def initialize(value, unit)
|
14
|
+
unit_symbol = DynamicViscosity::UNITS_SYMBOL[unit] || unit
|
15
|
+
@conversion_rate_for_one_unit = DynamicViscosity::CONVERSION_RATE
|
16
|
+
super(value, unit_symbol, DynamicViscosity::UNITS)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to(c_unit)
|
20
|
+
c_unit.downcase!
|
21
|
+
unit_symbol = DynamicViscosity::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless DynamicViscosity::UNITS.include?(unit_symbol)
|
23
|
+
DynamicViscosity.new(convert_to(unit_symbol), unit_symbol)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'convert_unit/base'
|
2
|
+
require 'convert_unit/pre_process/high_pressure/process'
|
3
|
+
|
4
|
+
module ConvertUnit
|
5
|
+
class HighPressure < Base
|
6
|
+
extend PreProcess::HighPressure
|
7
|
+
UNITS_SYMBOL = load_units_symbol
|
8
|
+
UNITS = load_available_units
|
9
|
+
CONVERSION_RATE = load_conversion_rate
|
10
|
+
|
11
|
+
attr_accessor :value, :unit
|
12
|
+
|
13
|
+
def initialize(value, unit)
|
14
|
+
unit_symbol = HighPressure::UNITS_SYMBOL[unit] || unit
|
15
|
+
@conversion_rate_for_one_unit = HighPressure::CONVERSION_RATE
|
16
|
+
super(value, unit_symbol, HighPressure::UNITS)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to(c_unit)
|
20
|
+
c_unit.downcase!
|
21
|
+
unit_symbol = HighPressure::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless HighPressure::UNITS.include?(unit_symbol)
|
23
|
+
HighPressure.new(convert_to(unit_symbol), unit_symbol)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'convert_unit/base'
|
2
|
+
require 'convert_unit/pre_process/kinematic_viscosity/process'
|
3
|
+
|
4
|
+
module ConvertUnit
|
5
|
+
class KinematicViscosity < Base
|
6
|
+
extend PreProcess::KinematicViscosity
|
7
|
+
UNITS_SYMBOL = load_units_symbol
|
8
|
+
UNITS = load_available_units
|
9
|
+
CONVERSION_RATE = load_conversion_rate
|
10
|
+
|
11
|
+
attr_accessor :value, :unit
|
12
|
+
|
13
|
+
def initialize(value, unit)
|
14
|
+
unit_symbol = KinematicViscosity::UNITS_SYMBOL[unit] || unit
|
15
|
+
@conversion_rate_for_one_unit = KinematicViscosity::CONVERSION_RATE
|
16
|
+
super(value, unit_symbol, KinematicViscosity::UNITS)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to(c_unit)
|
20
|
+
c_unit.downcase!
|
21
|
+
unit_symbol = KinematicViscosity::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless KinematicViscosity::UNITS.include?(unit_symbol)
|
23
|
+
KinematicViscosity.new(convert_to(unit_symbol), unit_symbol)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'convert_unit/base'
|
2
|
+
require 'convert_unit/pre_process/low_pressure/process'
|
3
|
+
|
4
|
+
module ConvertUnit
|
5
|
+
class LowPressure < Base
|
6
|
+
extend PreProcess::LowPressure
|
7
|
+
UNITS_SYMBOL = load_units_symbol
|
8
|
+
UNITS = load_available_units
|
9
|
+
CONVERSION_RATE = load_conversion_rate
|
10
|
+
|
11
|
+
attr_accessor :value, :unit
|
12
|
+
|
13
|
+
def initialize(value, unit)
|
14
|
+
unit_symbol = LowPressure::UNITS_SYMBOL[unit] || unit
|
15
|
+
@conversion_rate_for_one_unit = LowPressure::CONVERSION_RATE
|
16
|
+
super(value, unit_symbol, LowPressure::UNITS)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to(c_unit)
|
20
|
+
c_unit.downcase!
|
21
|
+
unit_symbol = LowPressure::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless LowPressure::UNITS.include?(unit_symbol)
|
23
|
+
LowPressure.new(convert_to(unit_symbol), unit_symbol)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'convert_unit/base'
|
2
|
+
require 'convert_unit/pre_process/mass_flow/process'
|
3
|
+
|
4
|
+
module ConvertUnit
|
5
|
+
class MassFlow < Base
|
6
|
+
extend PreProcess::MassFlow
|
7
|
+
UNITS_SYMBOL = load_units_symbol
|
8
|
+
UNITS = load_available_units
|
9
|
+
CONVERSION_RATE = load_conversion_rate
|
10
|
+
|
11
|
+
attr_accessor :value, :unit
|
12
|
+
|
13
|
+
def initialize(value, unit)
|
14
|
+
unit_symbol = MassFlow::UNITS_SYMBOL[unit] || unit
|
15
|
+
@conversion_rate_for_one_unit = MassFlow::CONVERSION_RATE
|
16
|
+
super(value, unit_symbol, MassFlow::UNITS)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to(c_unit)
|
20
|
+
c_unit.downcase!
|
21
|
+
unit_symbol = MassFlow::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless MassFlow::UNITS.include?(unit_symbol)
|
23
|
+
MassFlow.new(convert_to(unit_symbol), unit_symbol)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
bar:
|
2
|
+
bar: 1
|
3
|
+
psi: 14.50326
|
4
|
+
kpa: 100
|
5
|
+
mpa: 0.1
|
6
|
+
kgf/cm2: 1.01968
|
7
|
+
mm_hg: 750.0188
|
8
|
+
atm: 0.987167
|
9
|
+
psi:
|
10
|
+
bar: 0.06895
|
11
|
+
psi: 1
|
12
|
+
kpa: 6.895
|
13
|
+
mpa: 0.006895
|
14
|
+
kgf/cm2: 0.070307
|
15
|
+
mm_hg: 51.71379
|
16
|
+
atm: 0.068065
|
17
|
+
kpa:
|
18
|
+
bar: 0.01
|
19
|
+
psi: 0.1450
|
20
|
+
kpa: 1
|
21
|
+
mpa: 0.001
|
22
|
+
kgf/cm2: 0.01020
|
23
|
+
mm_hg: 7.5002
|
24
|
+
atm: 0.00987
|
25
|
+
mpa:
|
26
|
+
bar: 10
|
27
|
+
psi: 145.03
|
28
|
+
kpa: 1000
|
29
|
+
mpa: 1
|
30
|
+
kgf/cm2: 10.197
|
31
|
+
mm_hg: 7500.2
|
32
|
+
atm: 9.8717
|
33
|
+
kgf/cm2:
|
34
|
+
bar: 0.9807
|
35
|
+
psi: 14.22335
|
36
|
+
kpa: 98.07
|
37
|
+
mpa: 0.09807
|
38
|
+
kgf/cm2: 1
|
39
|
+
mm_hg: 735.5434
|
40
|
+
atm: 0.968115
|
41
|
+
mm_hg:
|
42
|
+
bar: 0.001333
|
43
|
+
psi: 0.019337
|
44
|
+
kpa: 0.13333
|
45
|
+
mpa: 0.000133
|
46
|
+
kgf/cm2: 0.00136
|
47
|
+
mm_hg: 1
|
48
|
+
atm: 0.001316
|
49
|
+
atm:
|
50
|
+
bar: 1.013
|
51
|
+
psi: 14.69181
|
52
|
+
kpa: 101.3
|
53
|
+
mpa: 0.1013
|
54
|
+
kgf/cm2: 1.032936
|
55
|
+
mm_hg: 759.769
|
56
|
+
atm: 1
|
@@ -0,0 +1,20 @@
|
|
1
|
+
cs:
|
2
|
+
cs: 1
|
3
|
+
st: 0.01
|
4
|
+
ft2/s: 0.000011
|
5
|
+
m2/s: 0.000001
|
6
|
+
st:
|
7
|
+
cs: 100
|
8
|
+
st: 1
|
9
|
+
ft2/s: 0.001076
|
10
|
+
m2/s: 0.0001
|
11
|
+
ft2/s:
|
12
|
+
cs: 92903
|
13
|
+
st: 929.03
|
14
|
+
ft2/s: 1
|
15
|
+
m2/s: 0.032903
|
16
|
+
m2/s:
|
17
|
+
cs: 1000000
|
18
|
+
st: 10000
|
19
|
+
ft2/s: 10.76392
|
20
|
+
m2/s: 1
|
@@ -0,0 +1,42 @@
|
|
1
|
+
mh2o:
|
2
|
+
mh2o: 1
|
3
|
+
fth2o: 3.280696
|
4
|
+
cmhg: 7.356339
|
5
|
+
inhg: 2.896043
|
6
|
+
inh2o: 39.36572
|
7
|
+
pa: 9806
|
8
|
+
fth2o:
|
9
|
+
mh2o: 0.304813
|
10
|
+
fth2o: 1
|
11
|
+
cmhg: 2.242311
|
12
|
+
inhg: 0.882753
|
13
|
+
inh2o: 11.9992
|
14
|
+
pa: 2989
|
15
|
+
cmhg:
|
16
|
+
mh2o: 0.135937
|
17
|
+
fth2o: 0.445969
|
18
|
+
cmhg: 1
|
19
|
+
inhg: 0.39368
|
20
|
+
inh2o: 5.351265
|
21
|
+
pa: 1333
|
22
|
+
inhg:
|
23
|
+
mh2o: 0.345299
|
24
|
+
fth2o: 1.13282
|
25
|
+
cmhg: 2.540135
|
26
|
+
inhg: 1
|
27
|
+
inh2o: 13.59293
|
28
|
+
pa: 3386
|
29
|
+
inh2o:
|
30
|
+
mh2o: 0.025403
|
31
|
+
fth2o: 0.083339
|
32
|
+
cmhg: 0.186872
|
33
|
+
inhg: 0.073568
|
34
|
+
inh2o: 1
|
35
|
+
pa: 249.1
|
36
|
+
pa:
|
37
|
+
mh2o: 0.000102
|
38
|
+
fth2o: 0.000335
|
39
|
+
cmhg: 0.00075
|
40
|
+
inhg: 0.000295
|
41
|
+
inh2o: 0.004014
|
42
|
+
pa: 1
|
@@ -0,0 +1,20 @@
|
|
1
|
+
kg/h:
|
2
|
+
kg/h: 1
|
3
|
+
lb/h: 2.204586
|
4
|
+
kg/s: 0.000278
|
5
|
+
t/h: 0.001
|
6
|
+
lb/h:
|
7
|
+
kg/h: 0.4536
|
8
|
+
lb/h: 1
|
9
|
+
kg/s: 0.000126
|
10
|
+
t/h: 0.000454
|
11
|
+
kg/s:
|
12
|
+
kg/h: 3600
|
13
|
+
lb/h: 7936.508
|
14
|
+
kg/s: 1
|
15
|
+
t/h: 3.6
|
16
|
+
t/h:
|
17
|
+
kg/h: 1000
|
18
|
+
lb/h: 2204.586
|
19
|
+
kg/s: 0.277778
|
20
|
+
t/h: 1
|
@@ -0,0 +1,42 @@
|
|
1
|
+
m/s:
|
2
|
+
m/s: 1
|
3
|
+
m/min: 59.988
|
4
|
+
km/h: 3.599712
|
5
|
+
ft/s: 3.28048
|
6
|
+
ft/min: 196.8504
|
7
|
+
mi/h: 2.237136
|
8
|
+
m/min:
|
9
|
+
m/s: 0.01667
|
10
|
+
m/min: 1
|
11
|
+
km/h: 0.060007
|
12
|
+
ft/s: 0.054692
|
13
|
+
ft/min: 3.281496
|
14
|
+
mi/h: 0.037293
|
15
|
+
km/h:
|
16
|
+
m/s: 0.2778
|
17
|
+
m/min: 16.66467
|
18
|
+
km/h: 1
|
19
|
+
ft/s: 0.911417
|
20
|
+
ft/min: 54.68504
|
21
|
+
mi/h: 0.621477
|
22
|
+
ft/s:
|
23
|
+
m/s: 0.3048
|
24
|
+
m/min: 18.28434
|
25
|
+
km/h: 1.097192
|
26
|
+
ft/s: 1
|
27
|
+
ft/min: 60
|
28
|
+
mi/h: 0.681879
|
29
|
+
ft/min:
|
30
|
+
m/s: 0.00508
|
31
|
+
m/min: 0.304739
|
32
|
+
km/h: 0.018287
|
33
|
+
ft/s: 0.016667
|
34
|
+
ft/min: 1
|
35
|
+
mi/h: 0.011365
|
36
|
+
mi/h:
|
37
|
+
m/s: 0.447
|
38
|
+
m/min: 26.81464
|
39
|
+
km/h: 1.609071
|
40
|
+
ft/s: 1.466535
|
41
|
+
ft/min: 87.99213
|
42
|
+
mi/h: 1
|
@@ -0,0 +1,20 @@
|
|
1
|
+
nm:
|
2
|
+
nm: 1
|
3
|
+
kgfm: 0.101972
|
4
|
+
ftlb: 0.737561
|
5
|
+
inlb: 8.850732
|
6
|
+
kgfm:
|
7
|
+
nm: 9.80665
|
8
|
+
kgfm: 1
|
9
|
+
ftlb: 7.233003
|
10
|
+
inlb: 86.79603
|
11
|
+
ftlb:
|
12
|
+
nm: 1.35582
|
13
|
+
kgfm: 0.138255
|
14
|
+
ftlb: 1
|
15
|
+
inlb: 12
|
16
|
+
inlb:
|
17
|
+
nm: 0.112985
|
18
|
+
kgfm: 0.011521
|
19
|
+
ftlb: 0.083333
|
20
|
+
inlb: 1
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'convert_unit/base'
|
2
|
+
require 'convert_unit/pre_process/speed/process'
|
3
|
+
|
4
|
+
module ConvertUnit
|
5
|
+
class Speed < Base
|
6
|
+
extend PreProcess::Speed
|
7
|
+
UNITS_SYMBOL = load_units_symbol
|
8
|
+
UNITS = load_available_units
|
9
|
+
CONVERSION_RATE = load_conversion_rate
|
10
|
+
|
11
|
+
attr_accessor :value, :unit
|
12
|
+
|
13
|
+
def initialize(value, unit)
|
14
|
+
unit_symbol = Speed::UNITS_SYMBOL[unit] || unit
|
15
|
+
@conversion_rate_for_one_unit = Speed::CONVERSION_RATE
|
16
|
+
super(value, unit_symbol, Speed::UNITS)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to(c_unit)
|
20
|
+
c_unit.downcase!
|
21
|
+
unit_symbol = Speed::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless Speed::UNITS.include?(unit_symbol)
|
23
|
+
Speed.new(convert_to(unit_symbol), unit_symbol)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'convert_unit/base'
|
2
|
+
require 'convert_unit/pre_process/torque/process'
|
3
|
+
|
4
|
+
module ConvertUnit
|
5
|
+
class Torque < Base
|
6
|
+
extend PreProcess::Torque
|
7
|
+
UNITS_SYMBOL = load_units_symbol
|
8
|
+
UNITS = load_available_units
|
9
|
+
CONVERSION_RATE = load_conversion_rate
|
10
|
+
|
11
|
+
attr_accessor :value, :unit
|
12
|
+
|
13
|
+
def initialize(value, unit)
|
14
|
+
unit_symbol = Torque::UNITS_SYMBOL[unit] || unit
|
15
|
+
@conversion_rate_for_one_unit = Torque::CONVERSION_RATE
|
16
|
+
super(value, unit_symbol, Torque::UNITS)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to(c_unit)
|
20
|
+
c_unit.downcase!
|
21
|
+
unit_symbol = Torque::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless Torque::UNITS.include?(unit_symbol)
|
23
|
+
Torque.new(convert_to(unit_symbol), unit_symbol)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/convert_unit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convert_unit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tanvir hasan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,8 +112,13 @@ files:
|
|
112
112
|
- lib/convert_unit/base.rb
|
113
113
|
- lib/convert_unit/convert_unit.rb
|
114
114
|
- lib/convert_unit/density.rb
|
115
|
+
- lib/convert_unit/dynamic_viscosity.rb
|
116
|
+
- lib/convert_unit/high_pressure.rb
|
117
|
+
- lib/convert_unit/kinematic_viscosity.rb
|
115
118
|
- lib/convert_unit/length.rb
|
119
|
+
- lib/convert_unit/low_pressure.rb
|
116
120
|
- lib/convert_unit/mass.rb
|
121
|
+
- lib/convert_unit/mass_flow.rb
|
117
122
|
- lib/convert_unit/pre_process/area/conversion_rate.yml
|
118
123
|
- lib/convert_unit/pre_process/area/process.rb
|
119
124
|
- lib/convert_unit/pre_process/area/units.yml
|
@@ -122,15 +127,43 @@ files:
|
|
122
127
|
- lib/convert_unit/pre_process/density/process.rb
|
123
128
|
- lib/convert_unit/pre_process/density/units.yml
|
124
129
|
- lib/convert_unit/pre_process/density/units_symbol.yml
|
130
|
+
- lib/convert_unit/pre_process/dynamic_viscosity/conversion_rate.yml
|
131
|
+
- lib/convert_unit/pre_process/dynamic_viscosity/process.rb
|
132
|
+
- lib/convert_unit/pre_process/dynamic_viscosity/units.yml
|
133
|
+
- lib/convert_unit/pre_process/dynamic_viscosity/units_symbol.yml
|
134
|
+
- lib/convert_unit/pre_process/high_pressure/conversion_rate.yml
|
135
|
+
- lib/convert_unit/pre_process/high_pressure/process.rb
|
136
|
+
- lib/convert_unit/pre_process/high_pressure/units.yml
|
137
|
+
- lib/convert_unit/pre_process/high_pressure/units_symbol.yml
|
138
|
+
- lib/convert_unit/pre_process/kinematic_viscosity/conversion_rate.yml
|
139
|
+
- lib/convert_unit/pre_process/kinematic_viscosity/process.rb
|
140
|
+
- lib/convert_unit/pre_process/kinematic_viscosity/units.yml
|
141
|
+
- lib/convert_unit/pre_process/kinematic_viscosity/units_symbol.yml
|
125
142
|
- lib/convert_unit/pre_process/length/conversion_rate.yml
|
126
143
|
- lib/convert_unit/pre_process/length/process.rb
|
127
144
|
- lib/convert_unit/pre_process/length/units.yml
|
128
145
|
- lib/convert_unit/pre_process/length/units_symbol.yml
|
129
146
|
- lib/convert_unit/pre_process/load.rb
|
147
|
+
- lib/convert_unit/pre_process/low_pressure/conversion_rate.yml
|
148
|
+
- lib/convert_unit/pre_process/low_pressure/process.rb
|
149
|
+
- lib/convert_unit/pre_process/low_pressure/units.yml
|
150
|
+
- lib/convert_unit/pre_process/low_pressure/units_symbol.yml
|
130
151
|
- lib/convert_unit/pre_process/mass/conversion_rate.yml
|
131
152
|
- lib/convert_unit/pre_process/mass/process.rb
|
132
153
|
- lib/convert_unit/pre_process/mass/units.yml
|
133
154
|
- lib/convert_unit/pre_process/mass/units_symbol.yml
|
155
|
+
- lib/convert_unit/pre_process/mass_flow/conversion_rate.yml
|
156
|
+
- lib/convert_unit/pre_process/mass_flow/process.rb
|
157
|
+
- lib/convert_unit/pre_process/mass_flow/units.yml
|
158
|
+
- lib/convert_unit/pre_process/mass_flow/units_symbol.yml
|
159
|
+
- lib/convert_unit/pre_process/speed/conversion_rate.yml
|
160
|
+
- lib/convert_unit/pre_process/speed/process.rb
|
161
|
+
- lib/convert_unit/pre_process/speed/units.yml
|
162
|
+
- lib/convert_unit/pre_process/speed/units_symbol.yml
|
163
|
+
- lib/convert_unit/pre_process/torque/conversion_rate.yml
|
164
|
+
- lib/convert_unit/pre_process/torque/process.rb
|
165
|
+
- lib/convert_unit/pre_process/torque/units.yml
|
166
|
+
- lib/convert_unit/pre_process/torque/units_symbol.yml
|
134
167
|
- lib/convert_unit/pre_process/volume/conversion_rate.yml
|
135
168
|
- lib/convert_unit/pre_process/volume/process.rb
|
136
169
|
- lib/convert_unit/pre_process/volume/units.yml
|
@@ -143,6 +176,8 @@ files:
|
|
143
176
|
- lib/convert_unit/pre_process/volumetric_liquid_flow/process.rb
|
144
177
|
- lib/convert_unit/pre_process/volumetric_liquid_flow/units.yml
|
145
178
|
- lib/convert_unit/pre_process/volumetric_liquid_flow/units_symbol.yml
|
179
|
+
- lib/convert_unit/speed.rb
|
180
|
+
- lib/convert_unit/torque.rb
|
146
181
|
- lib/convert_unit/version.rb
|
147
182
|
- lib/convert_unit/volume.rb
|
148
183
|
- lib/convert_unit/volumetric_gas_flow.rb
|