class Fitting::Statistics::Percent
Public Class Methods
new(divider, dividend)
click to toggle source
# File lib/fitting/statistics/percent.rb, line 4 def initialize(divider, dividend) @divider = divider @dividend = dividend end
Public Instance Methods
to_f()
click to toggle source
# File lib/fitting/statistics/percent.rb, line 9 def to_f return 0.to_f if @divider.zero? (@dividend.to_f / @divider.to_f * 100.0).round(2) end
to_s()
click to toggle source
# File lib/fitting/statistics/percent.rb, line 14 def to_s "#{@dividend} (#{to_f}% of #{@divider})" end