Class: Breeder::Worker

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#should_stopObject

Returns the value of attribute should_stop.



3
4
5
# File 'lib/breeder/worker.rb', line 3

def should_stop
  @should_stop
end

Instance Method Details

#do_workObject

User-defined worker should override this

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/breeder/worker.rb', line 20

def do_work
  raise NotImplementedError
end

#runObject



13
14
15
16
17
# File 'lib/breeder/worker.rb', line 13

def run
  until stop?
    do_work
  end
end

#stop!Object



9
10
11
# File 'lib/breeder/worker.rb', line 9

def stop!
  @should_stop = true
end

#stop?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/breeder/worker.rb', line 5

def stop?
  @should_stop
end