Installing r_odds
Add this line to your application's Gemfile:
gem 'r_odds'
or
$ gem install r_odds
then
require 'r_odds'
How to use the gem
Use the :convert
method to convert between any of the following formats: :american
, :decimal
, :fractional
or :implied_probability
ROdds.convert('+150', to: :decimal)
#=> 2.50
ROdds.convert('25%', to: :american)
#=> +300
You can also specify the format you're passing in for ambiguous formats like '1/2'
(which could be an implied probability or a fractional odd).
ROdds.convert('1/4', to: :decimal)
#=> 1.25
ROdds.convert('1/4', from: :implied_probability, to: :american)
#=> +300
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/georgewambold/r_odds. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the ROdds project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.