module Scrivito class CmsRestApi class RequestTimer MIN_REQUEST_TIME = 0.005 def initialize(max_duration) @finish_before = Time.now + max_duration end def finished? remaining_time <= MIN_REQUEST_TIME end def remaining_time [finish_before - Time.now, 0].max end def cover?(point_in_time) point_in_time <= finish_before end private attr_reader :finish_before end end end