Class: Teek::BackgroundNone::BackgroundWork Private

Inherits:
Object
  • Object
show all
Defined in:
lib/teek/background_none.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.

Defined Under Namespace

Classes: TaskContext

Instance Method Summary collapse

Constructor Details

#initialize(app, data, worker: nil, &block) ⇒ BackgroundWork

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 BackgroundWork.



19
20
21
22
23
24
25
26
27
28
# File 'lib/teek/background_none.rb', line 19

def initialize(app, data, worker: nil, &block)
  @app = app
  @data = data
  @work_block = block || (worker && proc { |t, d| worker.new.call(t, d) })
  @callbacks = { progress: nil, done: nil, message: nil }
  @message_queue = []
  @started = false
  @done = false
  @paused = false
end

Instance Method Details

#closeObject

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.



69
70
71
# File 'lib/teek/background_none.rb', line 69

def close
  self
end

#done?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.

Returns:

  • (Boolean)


73
74
75
# File 'lib/teek/background_none.rb', line 73

def done?
  @done
end

#on_done(&block) ⇒ Object

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.



36
37
38
39
40
# File 'lib/teek/background_none.rb', line 36

def on_done(&block)
  @callbacks[:done] = block
  maybe_start
  self
end

#on_message(&block) ⇒ Object

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.



42
43
44
45
# File 'lib/teek/background_none.rb', line 42

def on_message(&block)
  @callbacks[:message] = block
  self
end

#on_progress(&block) ⇒ Object

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.



30
31
32
33
34
# File 'lib/teek/background_none.rb', line 30

def on_progress(&block)
  @callbacks[:progress] = block
  maybe_start
  self
end

#pauseObject

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.



52
53
54
55
56
# File 'lib/teek/background_none.rb', line 52

def pause
  @paused = true
  send_message(:pause)
  self
end

#paused?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.

Returns:

  • (Boolean)


77
78
79
# File 'lib/teek/background_none.rb', line 77

def paused?
  @paused
end

#resumeObject

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.



58
59
60
61
62
# File 'lib/teek/background_none.rb', line 58

def resume
  @paused = false
  send_message(:resume)
  self
end

#send_message(msg) ⇒ Object

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.



47
48
49
50
# File 'lib/teek/background_none.rb', line 47

def send_message(msg)
  @message_queue << msg
  self
end

#startObject

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.



81
82
83
84
# File 'lib/teek/background_none.rb', line 81

def start
  maybe_start
  self
end

#stopObject

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.



64
65
66
67
# File 'lib/teek/background_none.rb', line 64

def stop
  send_message(:stop)
  self
end