Class: Camayoc::Handlers::Timing

Inherits:
Object
  • Object
show all
Defined in:
lib/camayoc/handlers/timing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(total = 0, count = 0, min = nil, max = nil) ⇒ Timing

Returns a new instance of Timing.



6
7
8
9
10
11
# File 'lib/camayoc/handlers/timing.rb', line 6

def initialize(total=0,count=0,min=nil,max=nil)
  self.total = total
  self.count = count
  self.max = max
  self.min = min
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



4
5
6
# File 'lib/camayoc/handlers/timing.rb', line 4

def count
  @count
end

#maxObject

Returns the value of attribute max.



4
5
6
# File 'lib/camayoc/handlers/timing.rb', line 4

def max
  @max
end

#minObject

Returns the value of attribute min.



4
5
6
# File 'lib/camayoc/handlers/timing.rb', line 4

def min
  @min
end

#totalObject

Returns the value of attribute total.



4
5
6
# File 'lib/camayoc/handlers/timing.rb', line 4

def total
  @total
end

Instance Method Details

#<<(ms) ⇒ Object



13
14
15
16
17
18
# File 'lib/camayoc/handlers/timing.rb', line 13

def <<(ms)
  @total += ms
  @count += 1
  @max = ms if @max.nil? || ms > @max
  @min = ms if @min.nil? || ms < @min
end

#averageObject



20
21
22
23
# File 'lib/camayoc/handlers/timing.rb', line 20

def average
  return nil if @count == 0
  @total/@count
end