Socket
Book a DemoInstallSign in
Socket

easy_divide

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy_divide

1.0.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

easy_divide

You can calculate the percentage with a simple method

install

Add this line to your application's Gemfile:

gem 'easy_divide'

And then execute:

$ bundle

Or install it yourself as:

$ gem install easy_divide

Usage

.ratio method displays the percentage of how far the number behind the previous one changed 100.ratio(50) #=> 2.0

$ 123.9.ratio(34.89) #=> 3.55116079105761

.percent method displays how much of the total number is occupied

$ 100.percent(50) #=> 0.6666666666666666
$ 123.9.percent(34.89) #=> 0.7802758360098242

both methods are also avaibale by multimple numbers

$ 100.ratio(50, 12) #=> 1.6129032258064515
$ 123.9.percent(34.89, 1.56) #=> 0.7726847521047707

.to_act method displays a real number of 100 fractions

$ 100.percent(50, 12).to_act #=> 161

if you set argument, it displays the decimal point

$ 100.percent(50, 12).to_act(2) => 161.29

.with_sign method add "%" string

$ 100.percent(50, 12).to_act(2).with_sign #=> "61.73%"

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/endoyuma/easy_divide. 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.

FAQs

Package last updated on 23 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.