lib/press_recovery.rb
33 lines · ruby
Project files
# frozen_string_literal: true
require_relative "press_results"
class PressRecovery
def initialize(stations:)
@stations = stations.dup.freeze
end
def assess(positions)
positions.filter_map { |snapshot| assess_position(snapshot) }.freeze
end
private
def assess_position(snapshot)
return nil unless snapshot.work
missing = missing_before(snapshot)
PositionAssessment.new(station: snapshot.station.name,
disposition: disposition_for(missing),
missing: missing)
end
def missing_before(snapshot)
index = @stations.index(snapshot.station)
@stations[0...index].map(&:fact).reject { |fact| snapshot.work.fact?(fact) }
end
def disposition_for(missing)
missing.empty? ? :resume : :quarantine
end
end
Read along in the manual: The Reloading Lab · Download the project (zip)