Sha256: b2d54b52c63e138b04a4f12b5fccd08e06f32224235aa6b6aae4e331aa6cd3e7

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

module Fitting
  class Route
    class Requests
      class Statistics
        def initialize(combine)
          @full_count = combine.full_cover.size
          @part_count = combine.partial_cover.size
          @no_count = combine.no_cover.size
        end

        def to_s
          @to_s ||= [
            "API requests with fully implemented responses: #{@full_count} (#{full_percent}% of #{total_count}).",
            "API requests with partially implemented responses: #{@part_count} (#{part_percent}% of #{total_count}).",
            "API requests with no implemented responses: #{@no_count} (#{no_percent}% of #{total_count})."
          ].join("\n")
        end

        def total_count
          @total_count ||= @full_count + @part_count + @no_count
        end

        def full_percent
          @full_percentage ||= 0.0 if total_count.zero?
          @full_percentage ||= (@full_count.to_f / total_count.to_f * 100.0).round(2)
        end

        def part_percent
          @part_percentage ||= 0.0 if total_count.zero?
          @part_percentage ||= (@part_count.to_f / total_count.to_f * 100.0).round(2)
        end

        def no_percent
          @no_percentage ||= 0.0 if total_count.zero?
          @no_percentage ||= (@no_count.to_f / total_count.to_f * 100.0).round(2)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fitting-2.2.0 lib/fitting/route/requests/statistics.rb
fitting-2.1.3 lib/fitting/route/requests/statistics.rb
fitting-2.1.2 lib/fitting/route/requests/statistics.rb
fitting-2.1.1 lib/fitting/route/requests/statistics.rb
fitting-2.1.0 lib/fitting/route/requests/statistics.rb