Class: FileScheduler::Scheduling
- Defined in:
- lib/file_scheduler/scheduling.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
-
#root ⇒ Object
Returns the value of attribute root.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
- #forced_contents ⇒ Object
- #forced_next ⇒ Object
-
#initialize(root, time) ⇒ Scheduling
constructor
A new instance of Scheduling.
- #next_with_log ⇒ Object (also: #next)
- #next_without_log ⇒ Object
- #schedulable?(content) ⇒ Boolean
- #schedulable_by_repeat?(content) ⇒ Boolean
- #schedulable_by_time?(content) ⇒ Boolean
- #schedulable_contents ⇒ Object
- #schedulable_next ⇒ Object
Constructor Details
#initialize(root, time) ⇒ Scheduling
Returns a new instance of Scheduling.
6 7 8 9 |
# File 'lib/file_scheduler/scheduling.rb', line 6 def initialize(root, time) @root = root @time = time end |
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
4 5 6 |
# File 'lib/file_scheduler/scheduling.rb', line 4 def log @log end |
#root ⇒ Object
Returns the value of attribute root.
4 5 6 |
# File 'lib/file_scheduler/scheduling.rb', line 4 def root @root end |
#time ⇒ Object
Returns the value of attribute time.
4 5 6 |
# File 'lib/file_scheduler/scheduling.rb', line 4 def time @time end |
Instance Method Details
#forced_contents ⇒ Object
37 38 39 |
# File 'lib/file_scheduler/scheduling.rb', line 37 def forced_contents schedulable_contents.select &:forced_started_time? end |
#forced_next ⇒ Object
41 42 43 |
# File 'lib/file_scheduler/scheduling.rb', line 41 def forced_next forced_contents.first end |
#next_with_log ⇒ Object Also known as: next
53 54 55 |
# File 'lib/file_scheduler/scheduling.rb', line 53 def next_with_log log.log(next_without_log) end |
#next_without_log ⇒ Object
49 50 51 |
# File 'lib/file_scheduler/scheduling.rb', line 49 def next_without_log forced_next or schedulable_next end |
#schedulable?(content) ⇒ Boolean
15 16 17 18 |
# File 'lib/file_scheduler/scheduling.rb', line 15 def schedulable?(content) schedulable_by_time?(content) and schedulable_by_repeat?(content) end |
#schedulable_by_repeat?(content) ⇒ Boolean
25 26 27 28 29 |
# File 'lib/file_scheduler/scheduling.rb', line 25 def schedulable_by_repeat?(content) content.repeat_constraints.nil? or log.distance(content).nil? or log.distance(content) >= content.repeat_constraints end |
#schedulable_by_time?(content) ⇒ Boolean
20 21 22 23 |
# File 'lib/file_scheduler/scheduling.rb', line 20 def schedulable_by_time?(content) content.time_constraints.nil? or content.time_constraints.matches?(time) end |
#schedulable_contents ⇒ Object
31 32 33 34 35 |
# File 'lib/file_scheduler/scheduling.rb', line 31 def schedulable_contents @schedulable_contents ||= root.contents.select do |content| schedulable? content end end |
#schedulable_next ⇒ Object
45 46 47 |
# File 'lib/file_scheduler/scheduling.rb', line 45 def schedulable_next schedulable_contents.shuffle.first end |