Class: SimplePvr::RecordingPlanner
- Inherits:
-
Object
- Object
- SimplePvr::RecordingPlanner
- Defined in:
- lib/simple_pvr/recording_planner.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ RecordingPlanner
constructor
A new instance of RecordingPlanner.
- #read ⇒ Object
Constructor Details
#initialize ⇒ RecordingPlanner
Returns a new instance of RecordingPlanner.
9 10 11 |
# File 'lib/simple_pvr/recording_planner.rb', line 9 def initialize @recordings = [] end |
Class Method Details
Instance Method Details
#read ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/simple_pvr/recording_planner.rb', line 13 def read schedules = Model::Schedule.all specifications = schedules.find_all {|s| s.type == :specification } exceptions = schedules.find_all {|s| s.type == :exception } specifications.each do |specification| programmes = programmes_matching(specification) adjust_end_time_of_specification(specification, programmes) adjust_end_time_of_exceptions(specification, programmes, exceptions) programmes_with_exceptions_removed = programmes.find_all {|programme| !matches_exception(programme, exceptions) } programmes_filtered_by_weekdays = programmes_with_exceptions_removed.find_all {|programme| on_allowed_weekday(programme, specification) } programmes_filtered_by_time_of_day = programmes_filtered_by_weekdays.find_all {|programme| at_allowed_time_of_day(programme, specification) } add_programmes(specification, programmes_filtered_by_time_of_day) end PvrInitializer.scheduler.recordings = @recordings end |