InoxConverter
Hi! Welcome to Inox Converter official page! Our gem is created to work like a 'swiss army knife' for Ruby developers, bringing a easy and reliable way to convert some formats and units that commonly appear during the developing process. You can: convert area, currency(real time), length, mass, volume and format time and date. You want to use one unit that doesn't exist in our gem? You can add that unit too! And more... As a framework you can extend our gem and create your own convertions type.
Installation
Add this line to your application's Gemfile:
gem 'inox_converter'
And then execute:
bundle install
Or install it yourself as:
gem install inox_converter
Usage
To make a conversion:
- valueToConvert: the value you want to convert
- firstUnit: actual unit -> string
- secondUnit: the unit you want to convert to -> string
Exemplos
InoxConverter.convertCurrency(valueToConvert, firstUnit, secondUnit)
InoxConverter.convertLenght(valueToConvert, firstUnit, secondUnit)
InoxConverter.convertVolume(valueToConvert, firstUnit, secondUnit)
InoxConverter.convertArea(valueToConvert, firstUnit, secondUnit)
InoxConverter.convertMass(valueToConvert, firstUnit, secondUnit)
InoxConverter.convertTime(valueToConvert, firstUnit, secondUnit)
InoxConverter.convertTimeFormat(timeToFormat, desiredFormat)
InoxConverter.convertDateFormat(dateToFormat, desiredFormat)
InoxConverter.convertCurrency(10, "USD", "BRL")
InoxConverter.convertLenght(10, 'meter', 'kilometer')
InoxConverter.convertDateFormat(Date.today, "DMY")
To add a unit:
- newUnit: name of the new unit to be added -> string - newRate: reason between new unit and base unitInoxConverter.addLenghtUnit(newUnit, newRate)
InoxConverter.addVolumeUnit(newUnit, newRate)
InoxConverter.addAreaUnit(newUnit, newRate)
InoxConverter.addMassUnit(newUnit, newRate)
InoxConverter.addTimeUnit(newUnit, newRate)
InoxConverter.addDateFormat(newFormat, newRate)
InoxConverter.addTimeFormat(newFormat, newRate)
If you want to add a lenght unit called MyUnit that is ten times greater than the base unit of lenght (meter), you should to this:
InoxConverter.addLenghtUnit('MyUnit', 10)
Base units:
- Area: squared meter
- Currency: dollar
- Length: meter
- Mass: gram
- Time: second
- Volume: liter
Usage
You can see all types and units to convert in this link: List of Units
We also have a full user manual in portuguese: Manual de Usuário
Manual in Englise: coming soon.
Contributing
First you must choose an issue or request for us to create a new one
Then clone or fork our Repository
Time to Code!
Run
bundle install
bash build.sh
That's it inox_converter is install in your machine and ready use.
Do your contribution.
Don't forget to make your test's!
We use Rspec
Run your tests with:rspec
License
The gem is available as open source under the terms of the MIT License.