Class: Agqr::Recorder::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/agqr/recorder/job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recorder) ⇒ Job

Returns a new instance of Job.



10
11
12
# File 'lib/agqr/recorder/job.rb', line 10

def initialize(recorder)
  @recorder = recorder
end

Instance Attribute Details

#programObject (readonly)

Returns the value of attribute program.



8
9
10
# File 'lib/agqr/recorder/job.rb', line 8

def program
  @program
end

#recorderObject (readonly)

Returns the value of attribute recorder.



8
9
10
# File 'lib/agqr/recorder/job.rb', line 8

def recorder
  @recorder
end

#threadObject (readonly)

Returns the value of attribute thread.



8
9
10
# File 'lib/agqr/recorder/job.rb', line 8

def thread
  @thread
end

Instance Method Details

#build(program) ⇒ Object



14
15
16
# File 'lib/agqr/recorder/job.rb', line 14

def build(program)
  @program = Program.new(program)
end

#startObject



18
19
20
21
22
23
24
# File 'lib/agqr/recorder/job.rb', line 18

def start
  @thread = Thread.new do
    Chrono::Trigger.new(program.schedule) do
      recorder.record self
    end.run
  end
end

#stopObject



26
27
28
# File 'lib/agqr/recorder/job.rb', line 26

def stop
  thread.kill
end