Sha256: 14cfd62af154fc2aad774f3cc37161d9348c5e6d3a0ddf7f64349ee30d422ae5

Contents?: true

Size: 929 Bytes

Versions: 10

Compression:

Stored size: 929 Bytes

Contents

# frozen_string_literal: true

# Close Show methods for Report class.
class Report
  ##
  # Calculate final values:
  # * grade
  # * max_weight
  # * good_weight,d
  # * fail_weight
  # * fail_counter
  def close
    app = Application.instance
    max = 0.0
    good = 0.0
    fail = 0.0
    fail_counter = 0
    @lines.each do |i|
      if i.class.to_s == 'Hash'
        max += i[:weight] if i[:weight].positive?
        if i[:check]
          good += i[:weight]
          @history += app.letter[:good]
        else
          fail += i[:weight]
          fail_counter += 1
          @history += app.letter[:bad]
        end
      end
    end
    @tail[:max_weight] = max
    @tail[:good_weight] = good
    @tail[:fail_weight] = fail
    @tail[:fail_counter] = fail_counter

    i = good.to_f / max.to_f
    i = 0 if i.nan?
    @tail[:grade] = (100.0 * i).round
    @tail[:grade] = 0 if @tail[:unique_fault].positive?
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
teuton-2.1.8 lib/teuton/report/close.rb
teuton-2.1.8dev1 lib/teuton/report/close.rb
teuton-2.1.7 lib/teuton/report/close.rb
teuton-2.1.6 lib/teuton/report/close.rb
teuton-2.1.5dev lib/teuton/report/close.rb
teuton-2.1.4 lib/teuton/report/close.rb
teuton-2.1.3 lib/teuton/report/close.rb
teuton-2.1.2 lib/teuton/report/close.rb
teuton-2.1.1 lib/teuton/report/close.rb
teuton-2.1.0 lib/teuton/report/close.rb