class Leafy::Core::Timer::Context

A timing context.

@see Timer#context()

Public Class Methods

new(timer, clock) click to toggle source
# File lib/leafy/core/timer.rb, line 16
def initialize(timer, clock)
  @timer = timer
  @clock = clock
  @startTime = clock.tick
end

Public Instance Methods

stop() click to toggle source

Updates the timer with the difference between current and start time. Call to this method will not reset the start time. Multiple calls result in multiple updates.

@return the elapsed time in nanoseconds

# File lib/leafy/core/timer.rb, line 26
def stop
  elapsed = @clock.tick - @startTime
  @timer.update(elapsed / 1000000000.0)
  elapsed
end