Class: Camayoc::Handlers::Timing
- Inherits:
-
Object
- Object
- Camayoc::Handlers::Timing
- Defined in:
- lib/camayoc/handlers/timing.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
- #<<(ms) ⇒ Object
- #average ⇒ Object
-
#initialize(total = 0, count = 0, min = nil, max = nil) ⇒ Timing
constructor
A new instance of Timing.
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
#count ⇒ Object
Returns the value of attribute count.
4 5 6 |
# File 'lib/camayoc/handlers/timing.rb', line 4 def count @count end |
#max ⇒ Object
Returns the value of attribute max.
4 5 6 |
# File 'lib/camayoc/handlers/timing.rb', line 4 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
4 5 6 |
# File 'lib/camayoc/handlers/timing.rb', line 4 def min @min end |
#total ⇒ Object
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 |
#average ⇒ Object
20 21 22 23 |
# File 'lib/camayoc/handlers/timing.rb', line 20 def average return nil if @count == 0 @total/@count end |