class Stopwatch::Timer

Overview

Timer

Object that behaves as a stop watch timer.

Defined in:

stopwatch.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def average : Float64 #

Average of times. If #time? if false this will raise an error.

@return [Float64,Error]


[View source]
def h : String #

Human display of total time elapsed in hours, minutes, and seconds.

@return [String] String of hh:mm:ss


[View source]
def ha : String #

Human representation of average seconds per #mark.

@return [String] String representation of average or empty for none.


[View source]
def last : Float64 | Nil #

Last time #marked.

@return [Float64,nil] Returns the last time #marked, or else nil.


[View source]
def mark : Time | Array(Float64) #

Start & Mark time with this #mark method.

@return [Time, Array] First time returns Time start. From then on it returns #times method result. @see #times


[View source]
def time? : Bool #

Boolean check for any times #marked. Must mark atleast twice for this to be true.

@return [true,false]


[View source]
def times : Array(Float64) #

A collection of times #marked. Each represented in Float64 of seconds since the last #mark.

@return [Array] Returns array of times marked.


[View source]
def total : Int32 | Float64 #

Total time accumulated.

@return [Integer,Float64] Returns total time since start.


[View source]