Class: ProgressMonitor::Display

Inherits:
Object
  • Object
show all
Defined in:
lib/progress_monitor/display.rb,
lib/progress_monitor/display/renderer.rb,
lib/progress_monitor/display/input_loop.rb,
lib/progress_monitor/display/timer_loop.rb,
lib/progress_monitor/display/message_loop.rb,
lib/progress_monitor/display/progress_bar.rb,
lib/progress_monitor/display/task_observer.rb

Defined Under Namespace

Classes: InputLoop, MessageLoop, ProgressBar, Renderer, TaskObserver, TimerLoop

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task) ⇒ Display

Returns a new instance of Display.



13
14
15
16
# File 'lib/progress_monitor/display.rb', line 13

def initialize(task)
  @task = task
  @queue = Queue.new
end

Instance Attribute Details

#taskObject (readonly)

Returns the value of attribute task.



11
12
13
# File 'lib/progress_monitor/display.rb', line 11

def task
  @task
end

Instance Method Details

#displayObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/progress_monitor/display.rb', line 18

def display
  @current_task = task

  @renderer = Renderer.new(task)
  @renderer.refresh

  task.add_observer TaskObserver.new(queue)

  @main_thread = Thread.current
  Thread.new { InputLoop.new(queue).perform }
  Thread.new { TimerLoop.new(queue).perform }
  Thread.new { MessageLoop.new(queue, @main_thread, @renderer).perform }
end