toy/image_optim

View on GitHub
lib/image_optim/timer.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

require 'image_optim/elapsed_time'

class ImageOptim
  # Hold start time and timeout
  class Timer
    include ElapsedTime

    def initialize(seconds)
      @start = now
      @seconds = seconds
    end

    def elapsed
      now - @start
    end

    def left
      @seconds - elapsed
    end

    alias_method :to_f, :left
  end
end