class Hiatus::FileCountThreshold
an example of threshold that could be stored somewhere file's really simple to implement.
Public Class Methods
new(file_path, threshold = 5)
click to toggle source
Calls superclass method
Hiatus::CountThreshold::new
# File lib/hiatus/extras/file_count_threshold.rb, line 5 def initialize(file_path, threshold = 5) @file_path = file_path super threshold end
Public Instance Methods
increment()
click to toggle source
Calls superclass method
Hiatus::CountThreshold#increment
# File lib/hiatus/extras/file_count_threshold.rb, line 10 def increment super serialize end
reached?()
click to toggle source
# File lib/hiatus/extras/file_count_threshold.rb, line 15 def reached? failure_count, threshold = *deserialize failure_count >= threshold end
reset()
click to toggle source
Calls superclass method
Hiatus::CountThreshold#reset
# File lib/hiatus/extras/file_count_threshold.rb, line 20 def reset super serialize end
Private Instance Methods
deserialize()
click to toggle source
# File lib/hiatus/extras/file_count_threshold.rb, line 27 def deserialize JSON.parse IO.binread(@file_path) end
serialize()
click to toggle source
# File lib/hiatus/extras/file_count_threshold.rb, line 31 def serialize IO.binwrite @file_path, JSON.dump([@failure_count, @threshold]) end