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
|