Sha256: e5be7e627f616fcd09554f2098a3b58cc8bac49478b64fa175a5a050b0c9354d

Contents?: true

Size: 375 Bytes

Versions: 24

Compression:

Stored size: 375 Bytes

Contents

module Fitting
  class Statistics
    class Percent
      def initialize(divider, dividend)
        @divider = divider
        @dividend = dividend
      end

      def to_f
        return 0.to_f if @divider.zero?
        (@dividend.to_f / @divider.to_f * 100.0).round(2)
      end

      def to_s
        "#{@dividend} (#{to_f}% of #{@divider})"
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
fitting-2.17.0 lib/fitting/statistics/percent.rb
fitting-2.16.1 lib/fitting/statistics/percent.rb
fitting-2.16.0 lib/fitting/statistics/percent.rb
fitting-2.15.0 lib/fitting/statistics/percent.rb
fitting-2.14.1 lib/fitting/statistics/percent.rb
fitting-2.14.0 lib/fitting/statistics/percent.rb
fitting-2.13.1 lib/fitting/statistics/percent.rb
fitting-2.13.0 lib/fitting/statistics/percent.rb
fitting-2.12.1 lib/fitting/statistics/percent.rb
fitting-2.12.0 lib/fitting/statistics/percent.rb
fitting-2.11.0 lib/fitting/statistics/percent.rb
fitting-2.10.0 lib/fitting/statistics/percent.rb
fitting-2.9.1 lib/fitting/statistics/percent.rb
fitting-2.9.0 lib/fitting/statistics/percent.rb
fitting-2.8.1 lib/fitting/statistics/percent.rb
fitting-2.8.0 lib/fitting/statistics/percent.rb
fitting-2.7.2 lib/fitting/statistics/percent.rb
fitting-2.7.1 lib/fitting/statistics/percent.rb
fitting-2.7.0 lib/fitting/statistics/percent.rb
fitting-2.6.0 lib/fitting/statistics/percent.rb