convert_unit 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHORS +1 -1
- data/CHANGELOG.md +11 -0
- data/README.md +7 -1
- data/_config.yml +1 -0
- data/lib/convert_unit/area.rb +1 -1
- data/lib/convert_unit/convert_unit.rb +7 -4
- data/lib/convert_unit/density.rb +26 -0
- data/lib/convert_unit/length.rb +1 -1
- data/lib/convert_unit/mass.rb +1 -1
- data/lib/convert_unit/pre_process/density/conversion_rate.yml +20 -0
- data/lib/convert_unit/pre_process/density/process.rb +14 -0
- data/lib/convert_unit/pre_process/density/units.yml +4 -0
- data/lib/convert_unit/pre_process/density/units_symbol.yml +4 -0
- data/lib/convert_unit/pre_process/volumetric_gas_flow/conversion_rate.yml +12 -0
- data/lib/convert_unit/pre_process/volumetric_gas_flow/process.rb +14 -0
- data/lib/convert_unit/pre_process/volumetric_gas_flow/units.yml +3 -0
- data/lib/convert_unit/pre_process/volumetric_gas_flow/units_symbol.yml +3 -0
- data/lib/convert_unit/pre_process/volumetric_liquid_flow/conversion_rate.yml +56 -0
- data/lib/convert_unit/pre_process/volumetric_liquid_flow/process.rb +14 -0
- data/lib/convert_unit/pre_process/volumetric_liquid_flow/units.yml +7 -0
- data/lib/convert_unit/pre_process/volumetric_liquid_flow/units_symbol.yml +8 -0
- data/lib/convert_unit/version.rb +1 -1
- data/lib/convert_unit/volume.rb +1 -1
- data/lib/convert_unit/volumetric_gas_flow.rb +26 -0
- data/lib/convert_unit/volumetric_liquid_flow.rb +26 -0
- data/lib/convert_unit.rb +8 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66168d3c3f3fa108bf70e021cce4e71402a24df5
|
4
|
+
data.tar.gz: 749fdb056d205f57d5ae24f0adc2a592eb613c7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0978366fc2c32f8404de0c16e1db922010627c588696d3aed8f12fb364e68dc882faf6b6117f0fbc785f6407b7264567d9e78cd8f385475f9efc3231a1f54b61'
|
7
|
+
data.tar.gz: e8fb0650f05b9155b6e89ac9c6c490e2784c067a4b3e7a9cf5efe2519dcf4aa66c3e9aeff234ff108279e7d9c342c41b349c37f3424bf8f8e33947accd3ea901
|
data/AUTHORS
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Tanvir Hasan
|
data/CHANGELOG.md
CHANGED
@@ -1,2 +1,13 @@
|
|
1
|
+
## v0.2.0
|
2
|
+
* Change module required location
|
3
|
+
* Add module self method for get available unit conversion class
|
4
|
+
* Add Density method conversion
|
5
|
+
* Add Volumetric liquid flow
|
6
|
+
* Add Volumetric gas flow
|
7
|
+
|
1
8
|
## v0.1.0
|
2
9
|
* initial release
|
10
|
+
* Length Unit
|
11
|
+
* Area Unit
|
12
|
+
* Mass Unit
|
13
|
+
* Volume Unit
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
[![Build Status](https://travis-ci.org/tanvir002700/convert_unit.svg?branch=master)](https://travis-ci.org/tanvir002700/convert_unit)
|
3
3
|
[![Coverage Status](https://coveralls.io/repos/github/tanvir002700/convert_unit/badge.svg?branch=master)](https://coveralls.io/github/tanvir002700/convert_unit?branch=master)
|
4
4
|
[![Maintainability](https://api.codeclimate.com/v1/badges/6e3e7ff7c7b040d1680d/maintainability)](https://codeclimate.com/github/tanvir002700/convert_unit/maintainability)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/convert_unit.svg)](https://rubygems.org/gems/convert_unit)
|
6
|
+
[![Downloads](https://img.shields.io/gem/dt/convert_unit.svg)](https://rubygems.org/gems/convert_unit)
|
5
7
|
[![GitHub last commit (branch)](https://img.shields.io/github/last-commit/tanvir002700/convert_unit/master.svg)](https://github.com/tanvir002700/convert_unit)
|
6
8
|
[![license](https://img.shields.io/github/license/tanvir002700/convert_unit.svg)](https://github.com/tanvir002700/convert_unit/blob/master/LICENSE)
|
7
9
|
|
@@ -43,7 +45,8 @@ ConvertUnit::Length.new(1, 'km') === ConvertUnit::Length.new(1000, 'm') #=> fals
|
|
43
45
|
# Arithmetic
|
44
46
|
ConvertUnit::Length.new(1, 'km') + ConvertUnit::Length.new(1, 'km') == ConvertUnit::Length.new(2, 'km')
|
45
47
|
ConvertUnit::Length.new(1, 'km') + ConvertUnit::Length.new(1000, 'm') == ConvertUnit::Length.new(2, 'km')
|
46
|
-
ConvertUnit::Length.new(1000, 'm') + ConvertUnit::Length.new(1, 'km') == ConvertUnit::Length.new(
|
48
|
+
ConvertUnit::Length.new(1000, 'm') + ConvertUnit::Length.new(1, 'km') == ConvertUnit::Length.new(2000, 'm')
|
49
|
+
ConvertUnit::Length.new(1000, 'm') - ConvertUnit::Length.new(1, 'km') == ConvertUnit::Length.new(0, 'm')
|
47
50
|
|
48
51
|
# Valid units argument list
|
49
52
|
ConvertUnit::Length::UNITS_SYMBOL #=> { "millimeter"=>"mm", "centimeter"=>"cm", "meter"=>"m",
|
@@ -62,6 +65,9 @@ Length | mm, cm, m, km, in, ft, yd, mi
|
|
62
65
|
Area | mm2, cm2, m2, in2, ft2, yd2
|
63
66
|
Mass | g, kg, tonne, sh_ton, l_ton, lb, oz
|
64
67
|
Volume | cm3, m3, ltr, in3, ft3, us_gal, imp_gal, us_brl
|
68
|
+
Density | g/ml kg/m3 lb/ft3 lb/in3
|
69
|
+
Volumetric Liquid flow | l/sec l/min m3 ft3/min ft3/hr gal/min brl/d
|
70
|
+
Volumetric Liquid flow | nm3/hr scfh scfm
|
65
71
|
## Contributing
|
66
72
|
|
67
73
|
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/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-architect
|
data/lib/convert_unit/area.rb
CHANGED
@@ -19,7 +19,7 @@ module ConvertUnit
|
|
19
19
|
def to(c_unit)
|
20
20
|
c_unit.downcase!
|
21
21
|
unit_symbol = Area::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
-
raise ArgumentError, '
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless Area::UNITS.include?(unit_symbol)
|
23
23
|
Area.new(convert_to(unit_symbol), unit_symbol)
|
24
24
|
end
|
25
25
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'convert_unit/base'
|
2
|
+
require 'convert_unit/pre_process/density/process'
|
3
|
+
|
4
|
+
module ConvertUnit
|
5
|
+
class Density < Base
|
6
|
+
extend PreProcess::Density
|
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 = Density::UNITS_SYMBOL[unit] || unit
|
15
|
+
@conversion_rate_for_one_unit = Density::CONVERSION_RATE
|
16
|
+
super(value, unit_symbol, Density::UNITS)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to(c_unit)
|
20
|
+
c_unit.downcase!
|
21
|
+
unit_symbol = Density::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless Density::UNITS.include?(unit_symbol)
|
23
|
+
Density.new(convert_to(unit_symbol), unit_symbol)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/convert_unit/length.rb
CHANGED
@@ -19,7 +19,7 @@ module ConvertUnit
|
|
19
19
|
def to(c_unit)
|
20
20
|
c_unit.downcase!
|
21
21
|
unit_symbol = Length::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
-
raise ArgumentError, '
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless Length::UNITS.include?(unit_symbol)
|
23
23
|
Length.new(convert_to(unit_symbol), unit_symbol)
|
24
24
|
end
|
25
25
|
end
|
data/lib/convert_unit/mass.rb
CHANGED
@@ -19,7 +19,7 @@ module ConvertUnit
|
|
19
19
|
def to(c_unit)
|
20
20
|
c_unit.downcase!
|
21
21
|
unit_symbol = Mass::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
-
raise ArgumentError, '
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless Mass::UNITS.include?(unit_symbol)
|
23
23
|
Mass.new(convert_to(unit_symbol), unit_symbol)
|
24
24
|
end
|
25
25
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
g/ml:
|
2
|
+
g/ml: 1
|
3
|
+
kg/m3: 1000
|
4
|
+
lb/ft3: 62.42197
|
5
|
+
lb/in3: 0.036127
|
6
|
+
kg/m3:
|
7
|
+
g/ml: 0.001
|
8
|
+
kg/m3: 1
|
9
|
+
lb/ft3: 0.062422
|
10
|
+
lb/in3: 0.000036
|
11
|
+
lb/ft3:
|
12
|
+
g/ml: 0.01602
|
13
|
+
kg/m3: 16.02
|
14
|
+
lb/ft3: 1
|
15
|
+
lb/in3: 0.000579
|
16
|
+
lb/in3:
|
17
|
+
g/ml: 27.68
|
18
|
+
kg/m3: 27680
|
19
|
+
lb/ft3: 1727.84
|
20
|
+
lb/in3: 1
|
@@ -0,0 +1,56 @@
|
|
1
|
+
l/sec:
|
2
|
+
l/sec: 1
|
3
|
+
l/min: 60
|
4
|
+
m3: 3.6
|
5
|
+
ft3/min: 2.119093
|
6
|
+
ft3/hr: 127.1197
|
7
|
+
gal/min: 15.85037
|
8
|
+
brl/d: 543.4783
|
9
|
+
l/min:
|
10
|
+
l/sec: 0.016666
|
11
|
+
l/min: 1
|
12
|
+
m3: 0.06
|
13
|
+
ft3/min: 0.035317
|
14
|
+
ft3/hr: 2.118577
|
15
|
+
gal/min: 0.264162
|
16
|
+
brl/d: 9.057609
|
17
|
+
m3:
|
18
|
+
l/sec: 0.277778
|
19
|
+
l/min: 16.6667
|
20
|
+
m3: 1
|
21
|
+
ft3/min: 0.588637
|
22
|
+
ft3/hr: 35.31102
|
23
|
+
gal/min: 4.40288
|
24
|
+
brl/d: 150.9661
|
25
|
+
ft3/min:
|
26
|
+
l/sec: 0.4719
|
27
|
+
l/min: 28.31513
|
28
|
+
m3: 1.69884
|
29
|
+
ft3/min: 1
|
30
|
+
ft3/hr: 60
|
31
|
+
gal/min: 7.479791
|
32
|
+
brl/d: 256.4674
|
33
|
+
ft3/hr:
|
34
|
+
l/sec: 0.007867
|
35
|
+
l/min: 0.472015
|
36
|
+
m3: 0.02832
|
37
|
+
ft3/min: 0.01667
|
38
|
+
ft3/hr: 1
|
39
|
+
gal/min: 0.124689
|
40
|
+
brl/d: 4.275326
|
41
|
+
gal/min:
|
42
|
+
l/sec: 0.06309
|
43
|
+
l/min: 3.785551
|
44
|
+
m3: 0.227124
|
45
|
+
ft3/min: 0.133694
|
46
|
+
ft3/hr: 8.019983
|
47
|
+
gal/min: 1
|
48
|
+
brl/d: 34.28804
|
49
|
+
brl/d:
|
50
|
+
l/sec: 0.00184
|
51
|
+
l/min: 0.110404
|
52
|
+
m3: 0.006624
|
53
|
+
ft3/min: 0.003899
|
54
|
+
ft3/hr: 0.2339
|
55
|
+
gal/min: 0.029165
|
56
|
+
brl/d: 1
|
data/lib/convert_unit/version.rb
CHANGED
data/lib/convert_unit/volume.rb
CHANGED
@@ -19,7 +19,7 @@ module ConvertUnit
|
|
19
19
|
def to(c_unit)
|
20
20
|
c_unit.downcase!
|
21
21
|
unit_symbol = Volume::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
-
raise ArgumentError, '
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless Volume::UNITS.include?(unit_symbol)
|
23
23
|
Volume.new(convert_to(unit_symbol), unit_symbol)
|
24
24
|
end
|
25
25
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'convert_unit/base'
|
2
|
+
require 'convert_unit/pre_process/volumetric_gas_flow/process'
|
3
|
+
|
4
|
+
module ConvertUnit
|
5
|
+
class VolumetricGasFlow < Base
|
6
|
+
extend PreProcess::VolumetricGasFlow
|
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 = VolumetricGasFlow::UNITS_SYMBOL[unit] || unit
|
15
|
+
@conversion_rate_for_one_unit = VolumetricGasFlow::CONVERSION_RATE
|
16
|
+
super(value, unit_symbol, VolumetricGasFlow::UNITS)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to(c_unit)
|
20
|
+
c_unit.downcase!
|
21
|
+
unit_symbol = VolumetricGasFlow::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless VolumetricGasFlow::UNITS.include?(unit_symbol)
|
23
|
+
VolumetricGasFlow.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/volumetric_liquid_flow/process'
|
3
|
+
|
4
|
+
module ConvertUnit
|
5
|
+
class VolumetricLiquidFlow < Base
|
6
|
+
extend PreProcess::VolumetricLiquidFlow
|
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 = VolumetricLiquidFlow::UNITS_SYMBOL[unit] || unit
|
15
|
+
@conversion_rate_for_one_unit = VolumetricLiquidFlow::CONVERSION_RATE
|
16
|
+
super(value, unit_symbol, VolumetricLiquidFlow::UNITS)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to(c_unit)
|
20
|
+
c_unit.downcase!
|
21
|
+
unit_symbol = VolumetricLiquidFlow::UNITS_SYMBOL[c_unit] || c_unit
|
22
|
+
raise ArgumentError, 'Impossible conversion type' unless VolumetricLiquidFlow::UNITS.include?(unit_symbol)
|
23
|
+
VolumetricLiquidFlow.new(convert_to(unit_symbol), unit_symbol)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/convert_unit.rb
CHANGED
@@ -1,2 +1,10 @@
|
|
1
1
|
require 'convert_unit/version'
|
2
2
|
require 'convert_unit/convert_unit'
|
3
|
+
|
4
|
+
require 'convert_unit/length'
|
5
|
+
require 'convert_unit/area'
|
6
|
+
require 'convert_unit/mass'
|
7
|
+
require 'convert_unit/volume'
|
8
|
+
require 'convert_unit/density'
|
9
|
+
require 'convert_unit/volumetric_liquid_flow'
|
10
|
+
require 'convert_unit/volumetric_gas_flow'
|
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: 0.2.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:
|
11
|
+
date: 2018-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- LICENSE.txt
|
104
104
|
- README.md
|
105
105
|
- Rakefile
|
106
|
+
- _config.yml
|
106
107
|
- bin/console
|
107
108
|
- bin/setup
|
108
109
|
- convert_unit.gemspec
|
@@ -110,12 +111,17 @@ files:
|
|
110
111
|
- lib/convert_unit/area.rb
|
111
112
|
- lib/convert_unit/base.rb
|
112
113
|
- lib/convert_unit/convert_unit.rb
|
114
|
+
- lib/convert_unit/density.rb
|
113
115
|
- lib/convert_unit/length.rb
|
114
116
|
- lib/convert_unit/mass.rb
|
115
117
|
- lib/convert_unit/pre_process/area/conversion_rate.yml
|
116
118
|
- lib/convert_unit/pre_process/area/process.rb
|
117
119
|
- lib/convert_unit/pre_process/area/units.yml
|
118
120
|
- lib/convert_unit/pre_process/area/units_symbol.yml
|
121
|
+
- lib/convert_unit/pre_process/density/conversion_rate.yml
|
122
|
+
- lib/convert_unit/pre_process/density/process.rb
|
123
|
+
- lib/convert_unit/pre_process/density/units.yml
|
124
|
+
- lib/convert_unit/pre_process/density/units_symbol.yml
|
119
125
|
- lib/convert_unit/pre_process/length/conversion_rate.yml
|
120
126
|
- lib/convert_unit/pre_process/length/process.rb
|
121
127
|
- lib/convert_unit/pre_process/length/units.yml
|
@@ -129,8 +135,18 @@ files:
|
|
129
135
|
- lib/convert_unit/pre_process/volume/process.rb
|
130
136
|
- lib/convert_unit/pre_process/volume/units.yml
|
131
137
|
- lib/convert_unit/pre_process/volume/units_symbol.yml
|
138
|
+
- lib/convert_unit/pre_process/volumetric_gas_flow/conversion_rate.yml
|
139
|
+
- lib/convert_unit/pre_process/volumetric_gas_flow/process.rb
|
140
|
+
- lib/convert_unit/pre_process/volumetric_gas_flow/units.yml
|
141
|
+
- lib/convert_unit/pre_process/volumetric_gas_flow/units_symbol.yml
|
142
|
+
- lib/convert_unit/pre_process/volumetric_liquid_flow/conversion_rate.yml
|
143
|
+
- lib/convert_unit/pre_process/volumetric_liquid_flow/process.rb
|
144
|
+
- lib/convert_unit/pre_process/volumetric_liquid_flow/units.yml
|
145
|
+
- lib/convert_unit/pre_process/volumetric_liquid_flow/units_symbol.yml
|
132
146
|
- lib/convert_unit/version.rb
|
133
147
|
- lib/convert_unit/volume.rb
|
148
|
+
- lib/convert_unit/volumetric_gas_flow.rb
|
149
|
+
- lib/convert_unit/volumetric_liquid_flow.rb
|
134
150
|
homepage: https://rubygems.org/gems/convert_unit
|
135
151
|
licenses:
|
136
152
|
- MIT
|