Class: Burner::Library::Sleep

Inherits:
Job
  • Object
show all
Defined in:
lib/burner/library/sleep.rb

Overview

Arbitrarily put thread to sleep for X number of seconds

Note: this does not use Payload#registers.

Instance Attribute Summary collapse

Attributes inherited from Job

#name

Instance Method Summary collapse

Methods included from Util::Arrayable

#array

Constructor Details

#initialize(name: '', seconds: 0) ⇒ Sleep

Returns a new instance of Sleep.



18
19
20
21
22
23
24
# File 'lib/burner/library/sleep.rb', line 18

def initialize(name: '', seconds: 0)
  super(name: name)

  @seconds = seconds.to_f

  freeze
end

Instance Attribute Details

#secondsObject (readonly)

Returns the value of attribute seconds.



16
17
18
# File 'lib/burner/library/sleep.rb', line 16

def seconds
  @seconds
end

Instance Method Details

#perform(output, _payload) ⇒ Object



26
27
28
29
30
# File 'lib/burner/library/sleep.rb', line 26

def perform(output, _payload)
  output.detail("Going to sleep for #{seconds} second(s)")

  Kernel.sleep(seconds)
end