Class: Fitting::Route::Requests::Statistics

Inherits:
Object
  • Object
show all
Defined in:
lib/fitting/route/requests/statistics.rb

Instance Method Summary collapse

Constructor Details

#initialize(combine) ⇒ Statistics

Returns a new instance of Statistics.



5
6
7
8
9
# File 'lib/fitting/route/requests/statistics.rb', line 5

def initialize(combine)
  @full_count = combine.full_cover.size
  @part_count = combine.partial_cover.size
  @no_count = combine.no_cover.size
end

Instance Method Details

#full_percentObject



23
24
25
26
# File 'lib/fitting/route/requests/statistics.rb', line 23

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

#no_percentObject



33
34
35
36
# File 'lib/fitting/route/requests/statistics.rb', line 33

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

#part_percentObject



28
29
30
31
# File 'lib/fitting/route/requests/statistics.rb', line 28

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

#to_sObject



11
12
13
14
15
16
17
# File 'lib/fitting/route/requests/statistics.rb', line 11

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

#total_countObject



19
20
21
# File 'lib/fitting/route/requests/statistics.rb', line 19

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