Sha256: 20173c0a0fb889c41a90f5640617c88a3c27a78a5cb2fbdd25c8cfd36a4148f2

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

# easy_divide
You can calculate the percentage with a simple method

# install
Add this line to your application's Gemfile:

```ruby
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](http://contributor-covenant.org) code of conduct.


# License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
easy_divide-1.0.1 README.md