Class: Archaeo::DownloadScheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/archaeo/download_scheduler.rb

Overview

Schedules and orders snapshot downloads by strategy and priority.

Supports multiple ordering strategies (newest_first, oldest_first, breadth_first, depth_first) and priority rules (html_first, smallest_first, largest_first) for intelligent download ordering.

Constant Summary collapse

STRATEGIES =
%i[newest_first oldest_first breadth_first depth_first].freeze
PRIORITIES =
%i[html_first smallest_first largest_first].freeze

Instance Method Summary collapse

Constructor Details

#initialize(strategy: :newest_first, priority: nil, max_file_size: nil, min_file_size: nil) ⇒ DownloadScheduler

Returns a new instance of DownloadScheduler.



13
14
15
16
17
18
19
20
21
22
# File 'lib/archaeo/download_scheduler.rb', line 13

def initialize(strategy: :newest_first, priority: nil,
               max_file_size: nil, min_file_size: nil)
  validate_strategy(strategy)
  validate_priority(priority) if priority

  @strategy = strategy
  @priority = priority
  @max_file_size = max_file_size
  @min_file_size = min_file_size
end

Instance Method Details

#schedule(snapshots) ⇒ Object



24
25
26
27
28
# File 'lib/archaeo/download_scheduler.rb', line 24

def schedule(snapshots)
  filtered = apply_size_filters(snapshots)
  ordered = apply_strategy(filtered)
  apply_priority(ordered)
end