Sha256: 47f5b02fb4035cc7bfc27216aabd358efd06acc0b1dd1c0b9ac29bd9fa3741cc

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

# encoding: utf-8
module JLDrill
    class Timer
        attr_reader :total, :startedAt
        
        def initialize
            reset
        end

        def reset
            @total = 0.0
            @startedAt = nil
        end

        def assign(timer)
            @total = timer.total
            @startedAt = timer.startedAt
        end
        
        def start
            stop
            @startedAt = Time.now
        end

        def running?
            !@startedAt.nil?
        end
        
        def stop
            if running?
                @total += Time.now.to_f - @startedAt.to_f
                @startedAt = nil
            end
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jldrill-0.6.0.1 lib/jldrill/model/Quiz/Timer.rb