Sha256: fe7fb4317783fbbb51780d90bc084626f443dcd9229624b4f107b27176f464a5

Contents?: true

Size: 781 Bytes

Versions: 2

Compression:

Stored size: 781 Bytes

Contents

require 'active_support/concern'

require 'network_executive/channel_schedule'

module NetworkExecutive
  module Scheduling
    extend ActiveSupport::Concern

    def whats_on_at?( time )
      schedule.find { |sch| sch.whats_on? time } || OffAirSchedule.new
    end

    def whats_on?
      whats_on_at? Time.now.change(sec:0)
    end

    def whats_on_between?( start, stop, interval = nil )
      schedule.whats_on_between? start, stop, interval
    end

    def schedule
      self.class.schedule
    end

    module ClassMethods
      def schedule( program = nil, options = {}, &block )
        @schedule ||= ChannelSchedule.new

        if block_given?
          @schedule.add program, options, &block
        else
          @schedule
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
network_executive-0.0.8 lib/network_executive/scheduling.rb
network_executive-0.0.7 lib/network_executive/scheduling.rb