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.



17
18
19
20
# File 'lib/mutant/timer.rb', line 17

def initialize(*arguments)
  super(*arguments)
  @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)


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

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:



42
43
44
# File 'lib/mutant/timer.rb', line 42

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)


49
50
51
# File 'lib/mutant/timer.rb', line 49

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