Sha256: a74f1dbc49f3b65afdce9a69fd519ae6e418a8b24e92e4d47da739dba345b4d2

Contents?: true

Size: 775 Bytes

Versions: 3

Compression:

Stored size: 775 Bytes

Contents

module NetworkExecutive
  class Producer
    cattr_accessor :running

    class << self

      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

      def run_scheduled_programming
        Network.channels.each do |channel|
          if scheduled_program = channel.whats_on?
            channel.show scheduled_program
          end
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
network_executive-0.0.4 lib/network_executive/producer.rb
network_executive-0.0.3 lib/network_executive/producer.rb
network_executive-0.0.2 lib/network_executive/producer.rb