summaryrefslogtreecommitdiff
path: root/lib/gitlab/sherlock/line_sample.rb
blob: 38df7a88e4e2d022b2578e2d0099c2437c1ae336 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Gitlab
  module Sherlock
    class LineSample
      attr_reader :duration, :events

      def initialize(duration, events)
        @duration = duration
        @events = events
      end

      def percentage_of(total_duration)
        (duration.to_f / total_duration) * 100.0
      end

      def majority_of?(total_duration)
        percentage_of(total_duration) >= 30
      end
    end
  end
end