Sha256: ab324e200df08ec9720dbaac4fde0ad17a14ecca9b1c770f85f9ce765a49a017

Contents?: true

Size: 664 Bytes

Versions: 1

Compression:

Stored size: 664 Bytes

Contents

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.5.1.7 lib/jldrill/model/Quiz/Timer.rb