class LogAnalyzer::Stat
Attributes
data[R]
type[R]
Public Class Methods
new(type:)
click to toggle source
# File lib/log_analyzer/stat.rb, line 5 def initialize(type:) @data = [] @type = type end
Public Instance Methods
avg()
click to toggle source
# File lib/log_analyzer/stat.rb, line 14 def avg @avg ||= (sum.to_f / count.to_f).round(2) end
count()
click to toggle source
# File lib/log_analyzer/stat.rb, line 18 def count; @count ||= @data.count; end
max()
click to toggle source
# File lib/log_analyzer/stat.rb, line 19 def max; @max ||= @data.max; end
min()
click to toggle source
# File lib/log_analyzer/stat.rb, line 20 def min; @min ||= @data.min; end
push(time)
click to toggle source
# File lib/log_analyzer/stat.rb, line 10 def push(time) @data << time.to_f end
Private Instance Methods
sum()
click to toggle source
# File lib/log_analyzer/stat.rb, line 23 def sum; @sum ||= @data.reduce(:+); end