Class: Mutant::Timer::Deadline Private

Inherits:
Object
  • Object
show all
Defined in:
lib/mutant/timer.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Direct Known Subclasses

None

Defined Under Namespace

Classes: None, Status

Instance Method Summary collapse

Constructor Details

#initialize(*arguments) ⇒ Deadline

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Deadline.



26
27
28
29
# File 'lib/mutant/timer.rb', line 26

def initialize(*arguments)
  super
  @start_at = timer.now
end

Instance Method Details

#expired?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test if deadline is expired

Returns:

  • (Boolean)


34
35
36
# File 'lib/mutant/timer.rb', line 34

def expired?
  time_left <= 0
end

#statusStatus

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Capture a deadline status

Returns:



51
52
53
# File 'lib/mutant/timer.rb', line 51

def status
  Status.new(time_left:)
end

#time_leftFloat?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Probe the time left

Returns:

  • (Float, nil)


58
59
60
# File 'lib/mutant/timer.rb', line 58

def time_left
  allowed_time - (timer.now - @start_at)
end