Module: Gera::Numeric
- Included in:
- Numeric
- Defined in:
- lib/gera/numeric.rb
Instance Method Summary collapse
-
#as_percentage_of(value) ⇒ Object
5.as_percentage_of(10) # => 50.0%.
-
#percent_of(value) ⇒ Object
10.percent_of(100) # => (10/1).
- #percents ⇒ Object
- #to_rate ⇒ Object
Instance Method Details
#as_percentage_of(value) ⇒ Object
5.as_percentage_of(10) # => 50.0%
17 18 19 |
# File 'lib/gera/numeric.rb', line 17 def as_percentage_of(value) (self.to_f * 100.0 / value).to_percent end |
#percent_of(value) ⇒ Object
10.percent_of(100) # => (10/1)
12 13 14 |
# File 'lib/gera/numeric.rb', line 12 def percent_of(value) value * to_percent end |
#percents ⇒ Object
7 8 9 |
# File 'lib/gera/numeric.rb', line 7 def percents self.to_percent end |
#to_rate ⇒ Object
3 4 5 |
# File 'lib/gera/numeric.rb', line 3 def to_rate RateFromMultiplicator.new(self) end |