inox_converter 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +41 -0
- data/lib/inox_converter/api/api.rb +77 -0
- data/lib/inox_converter/area.rb +33 -0
- data/lib/inox_converter/converter.rb +71 -0
- data/lib/inox_converter/currency.rb +14 -0
- data/lib/inox_converter/currency_adapter.rb +14 -0
- data/lib/inox_converter/date_format.rb +23 -0
- data/lib/inox_converter/length.rb +41 -0
- data/lib/inox_converter/mass.rb +30 -0
- data/lib/inox_converter/time.rb +22 -0
- data/lib/inox_converter/time_format.rb +22 -0
- data/lib/inox_converter/version.rb +3 -0
- data/lib/inox_converter/volume.rb +33 -0
- data/lib/inox_converter.rb +165 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 16c52be56598052d91b9bcb1b3730e2f7ac4a5f6
|
4
|
+
data.tar.gz: 3a76a8d1b4a74fe6a5093f8d22da03921631de5e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4968bcd70923e21f9fb5191ac676fc9959dcd45ee4e5dc110621751350d18495660e1e6990fc94226d525ec429f81c2eb6668fb420e957f92e7d9bceba3b6dc0
|
7
|
+
data.tar.gz: f0ac1b1744afdac693e83386e171d892d54b25811eee43e65a8ca2683a9db05fae1d98d6ae64d7b1738e81a4b1176fc9edae1896c438f0165729c32986e90d44
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# InoxConverter
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/inox_converter`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'inox_converter'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install inox_converter
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/inox_converter.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require "rest-client"
|
2
|
+
require "active_support/core_ext/hash"
|
3
|
+
module Api
|
4
|
+
class Api
|
5
|
+
|
6
|
+
@dados = ''
|
7
|
+
@data = true
|
8
|
+
|
9
|
+
#Consuming yahoo finances api and transform in hash for ruby
|
10
|
+
def consume_api
|
11
|
+
@dados = RestClient::Request.execute(method: :get, url: 'https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote')
|
12
|
+
hash_local = Hash.new
|
13
|
+
@hash_local = Hash.from_xml(@dados)
|
14
|
+
end
|
15
|
+
|
16
|
+
#Treating data in hash
|
17
|
+
def treat_data
|
18
|
+
@hash_inter = Hash.new
|
19
|
+
@hash = Hash.new
|
20
|
+
if validate_api_return
|
21
|
+
@hash_inter = @hash_local['list']['resources']['resource']
|
22
|
+
@hash_inter.each do |cout|
|
23
|
+
simbol_string = cout['field'][0].to_s
|
24
|
+
simbol = simbol_string.split("/")
|
25
|
+
@hash[simbol[1]] = cout['field'][1].to_f
|
26
|
+
end
|
27
|
+
else
|
28
|
+
@data = false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
#verifield return of consumir api
|
33
|
+
def validate_api_return
|
34
|
+
if @dados.nil?
|
35
|
+
return false
|
36
|
+
else
|
37
|
+
return true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
#verifield value in @hash for calcule currency convert
|
42
|
+
def return_hash_currency(valor)
|
43
|
+
if @hash[valor].nil?
|
44
|
+
return false
|
45
|
+
else
|
46
|
+
return true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def data_validate_api(firstUnit, secondUnit)
|
51
|
+
if @data == false || return_hash_currency(firstUnit) == false || return_hash_currency(secondUnit) == false
|
52
|
+
return false
|
53
|
+
else
|
54
|
+
return true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
#Template of execution sequence of the methods and return @hash
|
59
|
+
def dictionary_api(firstUnit, secondUnit)
|
60
|
+
consume_api
|
61
|
+
treat_data
|
62
|
+
data_validate_api(firstUnit, secondUnit)
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
#new metodo for convert currency
|
67
|
+
def convert_currency(valueToConvert, firstUnit, secondUnit)
|
68
|
+
|
69
|
+
if dictionary_api(firstUnit, secondUnit) == false
|
70
|
+
return 0
|
71
|
+
else
|
72
|
+
finalValue = (valueToConvert / @hash[firstUnit]) * @hash[secondUnit]
|
73
|
+
return finalValue
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module InoxConverter
|
2
|
+
class Area < Converter
|
3
|
+
|
4
|
+
# base unit: square meter
|
5
|
+
def initDictionary
|
6
|
+
@dictionary = Hash.new
|
7
|
+
@dictionary = {
|
8
|
+
"square kilometre" => 10**6,
|
9
|
+
"square kilometer" => 10**6,
|
10
|
+
"km2" => 10**6,
|
11
|
+
"square metre" => 1,
|
12
|
+
"square meter" => 1,
|
13
|
+
"m2" => 1,
|
14
|
+
"square centimeter"=> 10**-4,
|
15
|
+
"square centimetre"=> 10**-4,
|
16
|
+
"cm2"=> 10**-4,
|
17
|
+
"square mile" => 2.59**6,
|
18
|
+
"mi2" => 2.59**6,
|
19
|
+
"square yard" => 0.836127,
|
20
|
+
"yd2" => 0.836127,
|
21
|
+
"square foot" => 0.09290,
|
22
|
+
"ft2" => 0.09290,
|
23
|
+
"square inch" => 0.00064516,
|
24
|
+
"in2" => 0.00064516,
|
25
|
+
"hectare" => 10000,
|
26
|
+
"ha" => 10000,
|
27
|
+
"acre" => 4046.86,
|
28
|
+
"ac" => 4046.86
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module InoxConverter
|
2
|
+
class Converter
|
3
|
+
|
4
|
+
@dictionary = nil
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
puts "Initializing Converter"
|
8
|
+
self.initDictionary
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
# Template to convert
|
13
|
+
def convert(valueToConvert, firstUnit, secondUnit)
|
14
|
+
#First Step
|
15
|
+
finalValue = valueToConvert.round(10)
|
16
|
+
#Second Step
|
17
|
+
finalValue *= getInDictionary(firstUnit).round(10)
|
18
|
+
#Third step
|
19
|
+
finalValue /= getInDictionary(secondUnit).round(10)
|
20
|
+
#Fourth step
|
21
|
+
return finalValue.round(10)
|
22
|
+
end
|
23
|
+
|
24
|
+
def getInDictionary(unit)
|
25
|
+
return @dictionary[unit]
|
26
|
+
end
|
27
|
+
|
28
|
+
def addUnitInDictionary(newUnit, newRate)
|
29
|
+
# Non-optional implementation
|
30
|
+
raise NotImplementedError.new("Convert method not implemented")
|
31
|
+
end
|
32
|
+
|
33
|
+
def initDictionary
|
34
|
+
raise NotImplementedError.new("Dictionary not initialize")
|
35
|
+
end
|
36
|
+
|
37
|
+
# newUnit: name of the new unit to be added
|
38
|
+
# newRate: reason between new unit and base unit
|
39
|
+
# (example: kilometer it's 1000x greater than meter, so the newRate should be 1000)
|
40
|
+
# returns bool - true if succeed, false if fails
|
41
|
+
def addUnit(newUnit, newRate)
|
42
|
+
|
43
|
+
if @dictionary.nil?
|
44
|
+
@dictionary = Hash.new()
|
45
|
+
else
|
46
|
+
# do nothing
|
47
|
+
end
|
48
|
+
|
49
|
+
# certify if the key doesn't exist
|
50
|
+
if !@dictionary.has_key?(newUnit)
|
51
|
+
@dictionary[newUnit] = newRate
|
52
|
+
|
53
|
+
# verify if the key has been added
|
54
|
+
if @dictionary.has_key?(newUnit)
|
55
|
+
puts "key #{newUnit} added"
|
56
|
+
|
57
|
+
# return @dictionary
|
58
|
+
return true
|
59
|
+
else
|
60
|
+
# throw exception
|
61
|
+
return false
|
62
|
+
end
|
63
|
+
|
64
|
+
else
|
65
|
+
puts "key #{newUnit} already exists"
|
66
|
+
return false
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'inox_converter/api/api'
|
2
|
+
|
3
|
+
module InoxConverter
|
4
|
+
class CurrencyAdapter < Currency
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
# subscrible of metod convert in adapter
|
9
|
+
def convert(valueToConvert, firstUnit, secondUnit)
|
10
|
+
@api = Api::Api.new
|
11
|
+
@api.convert_currency(valueToConvert, firstUnit, secondUnit)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'date'
|
2
|
+
module InoxConverter
|
3
|
+
class DateFormat < Converter
|
4
|
+
|
5
|
+
|
6
|
+
# use values from https://en.wikipedia.org/wiki/Date_format_by_country
|
7
|
+
def initDictionary
|
8
|
+
@dictionary = Hash.new
|
9
|
+
@dictionary = {
|
10
|
+
"DMY" => "%d/%m/%Y",
|
11
|
+
"YMD" => "%Y/%m/%d",
|
12
|
+
"MDY" => "%m/%d/%Y"
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def formatDate(value, unit)
|
17
|
+
date = getInDictionary(unit)
|
18
|
+
newDate = value.strftime(date)
|
19
|
+
return newDate
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module InoxConverter
|
2
|
+
class Length < Converter
|
3
|
+
|
4
|
+
# base unit: meter
|
5
|
+
def initDictionary
|
6
|
+
@dictionary = Hash.new
|
7
|
+
@dictionary = {
|
8
|
+
"kilometre" => 1000,
|
9
|
+
"kilometer" => 1000,
|
10
|
+
"km" => 1000,
|
11
|
+
"hectometer" => 100,
|
12
|
+
"hectometre" => 100,
|
13
|
+
"hm" => 100,
|
14
|
+
"decameter" => 10,
|
15
|
+
"decametre" => 10,
|
16
|
+
"dam" => 10,
|
17
|
+
"metre" => 1,
|
18
|
+
"meter" => 1,
|
19
|
+
"m" => 1,
|
20
|
+
"decimeter" => 0.1,
|
21
|
+
"decimetre" => 0.1,
|
22
|
+
"dm" => 0.1,
|
23
|
+
"centimeter" => 0.01,
|
24
|
+
"centimetre" => 0.01,
|
25
|
+
"cm" => 0.01,
|
26
|
+
"milimeter" => 0.001,
|
27
|
+
"milimetre" => 0.001,
|
28
|
+
"mm" => 0.001,
|
29
|
+
"mile" => 1609.34,
|
30
|
+
"mi" => 1609.34,
|
31
|
+
"yard" => 0.9144,
|
32
|
+
"yd" => 0.9144,
|
33
|
+
"feet" => 0.3048,
|
34
|
+
"ft" => 0.3048,
|
35
|
+
"inch" => 0.0254,
|
36
|
+
"in" => 0.0254
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module InoxConverter
|
2
|
+
class Mass < Converter
|
3
|
+
|
4
|
+
# base unit: gram
|
5
|
+
def initDictionary
|
6
|
+
@dictionary = Hash.new
|
7
|
+
@dictionary = {
|
8
|
+
"tonne" => 10**6,
|
9
|
+
"metric ton" => 10**6,
|
10
|
+
"t" => 10**6,
|
11
|
+
"kilogram" => 1000,
|
12
|
+
"kg" => 1000,
|
13
|
+
"gram" => 1,
|
14
|
+
"g" => 1,
|
15
|
+
"miligram" => 0.001,
|
16
|
+
"mg" => 0.001,
|
17
|
+
"microgram" => 10**-6,
|
18
|
+
"imperial ton" => 1016000,
|
19
|
+
"us ton" => 907185,
|
20
|
+
"stone" => 6350.29,
|
21
|
+
"st" => 6350.29,
|
22
|
+
"pound" => 453.592,
|
23
|
+
"lb" => 453.592,
|
24
|
+
"ounce" => 28.349,
|
25
|
+
"oz" => 28.349
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module InoxConverter
|
2
|
+
class Time < Converter
|
3
|
+
|
4
|
+
# base unit: seconds
|
5
|
+
def initDictionary
|
6
|
+
@dictionary = Hash.new
|
7
|
+
@dictionary = {
|
8
|
+
"second" => 1,
|
9
|
+
"s" => 1,
|
10
|
+
"minute" => 60,
|
11
|
+
"min" => 60,
|
12
|
+
"hour" => 60*60,
|
13
|
+
"h" => 60*60,
|
14
|
+
"day" => 60*60*24,
|
15
|
+
"week" => 60*60*24*7,
|
16
|
+
"year" => 60*60*24*365,
|
17
|
+
"leap year" => 60*60*24*366
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'time'
|
2
|
+
module InoxConverter
|
3
|
+
class TimeFormat < Converter
|
4
|
+
|
5
|
+
def initDictionary
|
6
|
+
@dictionary = Hash.new
|
7
|
+
@dictionary = {
|
8
|
+
"24hm" => "%R",
|
9
|
+
"12hm" => "%I:%M %p",
|
10
|
+
"24hms" => "%X",
|
11
|
+
"12hms" => "%I:%M:%S %p"
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def formatTime(value, unit)
|
16
|
+
time = getInDictionary(unit)
|
17
|
+
newTime = value.strftime(time)
|
18
|
+
return newTime
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module InoxConverter
|
2
|
+
class Volume < Converter
|
3
|
+
|
4
|
+
# base unit: liter
|
5
|
+
def initDictionary
|
6
|
+
@dictionary = Hash.new
|
7
|
+
@dictionary = {
|
8
|
+
"cubicmetre" => 1000,
|
9
|
+
"m3" => 1000,
|
10
|
+
"decaliter" => 10,
|
11
|
+
"dal" => 10,
|
12
|
+
"litre" => 1,
|
13
|
+
"liter" => 1,
|
14
|
+
"l" => 1,
|
15
|
+
"deciliter" => 0.1,
|
16
|
+
"decilitre" => 0.1,
|
17
|
+
"dl" => 0.1,
|
18
|
+
"centilitre" => 0.01,
|
19
|
+
"centiliter" => 0.01,
|
20
|
+
"cl" => 0.01,
|
21
|
+
"mililitre" => 0.001,
|
22
|
+
"mililiter" => 0.001,
|
23
|
+
"ml" => 0.001,
|
24
|
+
"glass" => 0.240,
|
25
|
+
"teaspoon" => 0.00492892,
|
26
|
+
"tablespoon" => 0.0147868,
|
27
|
+
"cubicfoot" => 28.3168,
|
28
|
+
"ft3" => 28.3168
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require "inox_converter/version"
|
2
|
+
require "inox_converter/converter"
|
3
|
+
require "inox_converter/area"
|
4
|
+
require "inox_converter/length"
|
5
|
+
require "inox_converter/mass"
|
6
|
+
require "inox_converter/volume"
|
7
|
+
require "inox_converter/time"
|
8
|
+
require "inox_converter/currency"
|
9
|
+
require "inox_converter/date_format"
|
10
|
+
require "inox_converter/time_format"
|
11
|
+
require "inox_converter/currency_adapter"
|
12
|
+
|
13
|
+
module InoxConverter
|
14
|
+
|
15
|
+
# Facade
|
16
|
+
# Conversion methods
|
17
|
+
|
18
|
+
def self.convertDateFormat(dateToConvert, desiredFormat)
|
19
|
+
puts "Date Formater"
|
20
|
+
self.newDateFormatInstance
|
21
|
+
@dateFormater.formatDate(dateToConvert, desiredFormat)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.convertTimeFormat(timeToConvert, desiredFormat)
|
25
|
+
puts "Time Formater"
|
26
|
+
self.newTimeFormatInstance
|
27
|
+
@timeFormater.formatTime(timeToConvert, desiredFormat)
|
28
|
+
end
|
29
|
+
|
30
|
+
# firstUnit = actual unit
|
31
|
+
# secondUnit = final unit
|
32
|
+
# returns the value converted
|
33
|
+
def self.convertCurrency(valueToConvert, firstUnit, secondUnit)
|
34
|
+
puts "Currency conversion"
|
35
|
+
currencyConverter = InoxConverter::CurrencyAdapter.new()
|
36
|
+
currencyConverter.convert(valueToConvert, firstUnit, secondUnit)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.convertLenght(valueToConvert, firstUnit, secondUnit)
|
40
|
+
puts "Lenght convertion"
|
41
|
+
self.newLenghtInstance
|
42
|
+
@lengthConverter.convert(valueToConvert, firstUnit, secondUnit)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.convertVolume(valueToConvert, firstUnit, secondUnit)
|
46
|
+
puts "Volume convertion"
|
47
|
+
self.newVolumeInstance
|
48
|
+
@volumeConverter.convert(valueToConvert, firstUnit, secondUnit)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.convertArea(valueToConvert, firstUnit, secondUnit)
|
52
|
+
puts "Area convertion"
|
53
|
+
self.newAreaInstance
|
54
|
+
@areaConverter.convert(valueToConvert, firstUnit, secondUnit)
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.convertMass(valueToConvert, firstUnit, secondUnit)
|
58
|
+
puts "Mass convertion"
|
59
|
+
self.newMassInstance
|
60
|
+
@massConverter.convert(valueToConvert, firstUnit, secondUnit)
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.convertTime(valueToConvert, firstUnit, secondUnit)
|
64
|
+
puts "Time convertion"
|
65
|
+
self.newTimeInstance
|
66
|
+
@timeConverter.convert(valueToConvert, firstUnit, secondUnit)
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
# Add unit methods
|
71
|
+
|
72
|
+
def self.addLenghtUnit(newUnit, newRate)
|
73
|
+
self.newLenghtInstance
|
74
|
+
@lengthConverter.addUnit(newUnit, newRate)
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.addVolumeUnit(newUnit, newRate)
|
78
|
+
self.newVolumeInstance
|
79
|
+
@volumeConverter.addUnit(newUnit, newRate)
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.addAreaUnit(newUnit, newRate)
|
83
|
+
self.newAreaInstance
|
84
|
+
@areaConverter.addUnit(newUnit, newRate)
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.addMassUnit(newUnit, newRate)
|
88
|
+
self.newMassInstance
|
89
|
+
@massConverter.addUnit(newUnit, newRate)
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.addTimeUnit(newUnit, newRate)
|
93
|
+
self.newTimeInstance
|
94
|
+
@timeConverter.addUnit(newUnit, newRate)
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.addDateFormat(newFormat, newRate)
|
98
|
+
self.newDateFormatInstance
|
99
|
+
@dateFormater.addUnit(newFormat, newRate)
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.addTimeFormat(newFormat, newRate)
|
103
|
+
self.newTimeFormatInstance
|
104
|
+
@timeFormater.addUnit(newFormat, newRate)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Instantiation methods
|
108
|
+
|
109
|
+
def self.newLenghtInstance()
|
110
|
+
if @lengthConverter.nil?
|
111
|
+
@lengthConverter = Length.new()
|
112
|
+
else
|
113
|
+
# do nothing
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.newDateFormatInstance()
|
118
|
+
if @dateFormater.nil?
|
119
|
+
@dateFormater = DateFormat.new()
|
120
|
+
else
|
121
|
+
# do nothing
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.newTimeFormatInstance()
|
126
|
+
if @timeFormater.nil?
|
127
|
+
@timeFormater = TimeFormat.new()
|
128
|
+
else
|
129
|
+
# do nothing
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.newVolumeInstance()
|
134
|
+
if @volumeConverter.nil?
|
135
|
+
@volumeConverter = Volume.new()
|
136
|
+
else
|
137
|
+
# do nothing
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.newAreaInstance()
|
142
|
+
if @areaConverter.nil?
|
143
|
+
@areaConverter = Area.new()
|
144
|
+
else
|
145
|
+
# do nothing
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def self.newMassInstance()
|
150
|
+
if @massConverter.nil?
|
151
|
+
@massConverter = Mass.new()
|
152
|
+
else
|
153
|
+
# do nothing
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def self.newTimeInstance()
|
158
|
+
if @timeConverter.nil?
|
159
|
+
@timeConverter = Time.new()
|
160
|
+
else
|
161
|
+
# do nothing
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: inox_converter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lucas Andrade
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Convert currency, temperature, lenght...
|
42
|
+
email:
|
43
|
+
- lucasandradeunb@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- README.md
|
49
|
+
- lib/inox_converter.rb
|
50
|
+
- lib/inox_converter/api/api.rb
|
51
|
+
- lib/inox_converter/area.rb
|
52
|
+
- lib/inox_converter/converter.rb
|
53
|
+
- lib/inox_converter/currency.rb
|
54
|
+
- lib/inox_converter/currency_adapter.rb
|
55
|
+
- lib/inox_converter/date_format.rb
|
56
|
+
- lib/inox_converter/length.rb
|
57
|
+
- lib/inox_converter/mass.rb
|
58
|
+
- lib/inox_converter/time.rb
|
59
|
+
- lib/inox_converter/time_format.rb
|
60
|
+
- lib/inox_converter/version.rb
|
61
|
+
- lib/inox_converter/volume.rb
|
62
|
+
homepage: ''
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.5.1
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: The ultimate converter gem
|
86
|
+
test_files: []
|