Class: NetworkExecutive::ChannelSchedule

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

Instance Method Summary collapse

Instance Method Details

#add(program, options = {}, &block) ⇒ Object



8
9
10
# File 'lib/network_executive/channel_schedule.rb', line 8

def add( program, options = {}, &block )
  unshift ProgramSchedule.new( program, options, &block )
end

#whats_on_between?(start, stop, interval) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/network_executive/channel_schedule.rb', line 12

def whats_on_between?( start, stop, interval )
  cursor   = start.dup
  programs = []

  until cursor > stop do
    program    = find_program_occurring_at( cursor )

    occurrence = program.occurrence_at cursor

    if repeated_off_air?( programs, program )
      program, occurrence, remainder = extend_off_air( programs, program, stop )
    else
      remainder = time_left( cursor, occurrence.end_time, stop )
    end

    portion   = remainder / (stop - start) * 100
    step      = occurrence.end_time - cursor

    programs << ScheduledProgram.new( program, occurrence, remainder, portion )

    cursor += step + 1
  end

  programs
end