class Alien::AlienBlockTimer
Public Class Methods
new(description="") { || ... }
click to toggle source
Setup the timer and pass in an optional description. If there is an associated block with the call, execute a timing measurment.
# File lib/alien/alienblocktimer.rb, line 70 def initialize (description="",&block) @t1=Time.now @measurement = "Timer initialized." unless block.nil? measure(description){yield} end end
Public Instance Methods
elapsed()
click to toggle source
The time since we called start or since the class was initialized.
# File lib/alien/alienblocktimer.rb, line 100 def elapsed Time.now - @t1 end
inspect()
click to toggle source
# File lib/alien/alienblocktimer.rb, line 104 def inspect @measurement end
measure(description="") { || ... }
click to toggle source
Measure the execution time for an asscociated code block.
# File lib/alien/alienblocktimer.rb, line 80 def measure(description="", &block) start unless block.nil? yield @measurement = description + elapsed.to_s else #Error message Haiku. :) @measurement = "No block to measure. Your timer waits patiently. Give him one to use." end end
start()
click to toggle source
Grab a start time
# File lib/alien/alienblocktimer.rb, line 95 def start @t1=Time.now end
to_s()
click to toggle source
# File lib/alien/alienblocktimer.rb, line 108 def to_s @measurement end