Class: StorageGuardian::ColdDetector
- Inherits:
-
Object
- Object
- StorageGuardian::ColdDetector
- Defined in:
- lib/storage_guardian/cold_detector.rb
Instance Method Summary collapse
- #detect ⇒ Object
-
#initialize(entries, threshold_days) ⇒ ColdDetector
constructor
A new instance of ColdDetector.
Constructor Details
#initialize(entries, threshold_days) ⇒ ColdDetector
Returns a new instance of ColdDetector.
5 6 7 8 9 |
# File 'lib/storage_guardian/cold_detector.rb', line 5 def initialize(entries, threshold_days) @entries = entries @threshold_days = threshold_days @cutoff = Time.now - (threshold_days * 86400) end |
Instance Method Details
#detect ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/storage_guardian/cold_detector.rb', line 11 def detect @entries.select { |e| e.mtime < @cutoff }.map do |e| { type: :cold_file, severity: :low, path: e.path, size_mb: (e.size / 1024.0 / 1024.0).round(2), last_modified: e.mtime, days_old: ((Time.now - e.mtime) / 86400).round, message: "File #{e.path} not modified for #{((Time.now - e.mtime) / 86400).round} days (#{(e.size / 1024.0 / 1024.0).round(2)}MB)" } end end |