Class: Patada::Task

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

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Task

Returns a new instance of Task.

Raises:

  • (::MissingBlockError)


10
11
12
13
# File 'lib/patada.rb', line 10

def initialize &block
  raise ::MissingBlockError unless block_given?
  @proc = Proc.new(&block)
end

Instance Method Details

#joinObject



19
20
21
# File 'lib/patada.rb', line 19

def join
  @thread.join
end

#killObject



23
24
25
# File 'lib/patada.rb', line 23

def kill
  @thread.kill
end

#runObject



15
16
17
# File 'lib/patada.rb', line 15

def run
  @thread = Thread.new { @proc.call }
end