Project

konvert

0.0
No commit activity in last 3 years
No release in over 3 years
Konvert is a Ruby command line gem that lets you convert between different currencies and perform arithmetic operations on them from the command line. Just set the currency rates and have fun..
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
>= 0
~> 10.0
>= 0
 Project Readme

Konvert

Konvert is a Ruby command line gem that lets you convert between different currencies and perform arithmetic operations on them from the command line. Just set the currency rates and have fun..

Installation

install it as:

$ gem install konvert

Usage

1- After installing the gem, enter irb console and require konvert:

irb(main): require 'konvert'

2- Configure the currency rates with respect to a base currency (here EUR):

irb(main): Konvert::Money.conversion_rates('EUR', {
    'USD'     => 1.11,
    'Bitcoin' => 0.0047
  })

3- You can perform the operations now. Examples:

  1. Create a Money object
irb(main): five_euro = Konvert::Money.new(5,'EUR)
  1. Convert to different currency
irb(main): five_euro.convert_to('USD') 
  1. Add two Money objects. They can be of same or different currencies
irb(main): fifty_eur + twenty_dollars                # => 68.02 EUR
irb(main): fifty_eur - twenty_dollars                  # => 31.98 EUR
  1. Divide or multiply a Money object with an integer
irb(main): fifty_eur / 2                         # => 25 EUR
irb(main): twenty_dollars * 3             # => 60 USD
  1. Perform Comparisons (same currencies or in different currencies):
irb(main): twenty_dollars == Konvert::Money.new(20, 'USD')          # => true
irb(main): twenty_dollars == Konvert::Money.new(30, 'USD')          # => false
irb(main): twenty_dollars > Konvert::Money.new(5, 'USD')               # => true
irb(main): twenty_dollars < fifty_eur                                    # => true

License

The gem is available as open source under the terms of the MIT License.