Sha256: ffaaa098f37ba764f2137d72dd60655d7f4bf85339a8e6417e2a16b28ff68ff4
Contents?: true
Size: 605 Bytes
Versions: 4
Compression:
Stored size: 605 Bytes
Contents
module Maths # Public: Represents a number that should be formatted as a percentage class Percentage < BigDecimal # Pretty much idential to a BigDecimal # Public: Builds out a fraction by the numerator and denominator def self.build(numerator, denominator) numerator = BigDecimal.new(numerator.to_s) denominator = BigDecimal.new(denominator.to_s) Percentage.new(((numerator / denominator) * 100).to_s) end # Public: Calculates the % change of from to to def self.change(from, to) Percentage.new((((to / from) - 1) * 100).to_s) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
maths-0.0.14 | lib/maths/percentage.rb |
maths-0.0.13 | lib/maths/percentage.rb |
maths-0.0.12 | lib/maths/percentage.rb |
maths-0.0.11 | lib/maths/percentage.rb |