Class: NetworkExecutive::Producer

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

Class Method Summary collapse

Class Method Details

.run!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/network_executive/producer.rb', line 7

def run!
  # Run whatever should be on right now
  run_scheduled_programming

  now = Time.now

  next_tick = ( now.change( sec:0 ) + 1.minute ) - now

  # Wait for the next 1-minute interval
  EM.add_timer( next_tick ) do
    run_scheduled_programming

    # Setup the main 1-minute loop
    EM.add_periodic_timer( 60 ) do
      run_scheduled_programming
    end
  end
end

.run_scheduled_programmingObject



26
27
28
29
30
31
32
# File 'lib/network_executive/producer.rb', line 26

def run_scheduled_programming
  Rails.logger.info "\n\n"

  Network.channels.each do |channel|
    channel.play channel.whats_on?
  end
end