Class: Hiatus::FileCountThreshold

Inherits:
CountThreshold show all
Defined in:
lib/hiatus/extras/file_count_threshold.rb

Overview

an example of threshold that could be stored somewhere file’s really simple to implement.

Instance Method Summary collapse

Methods inherited from CountThreshold

#touch

Constructor Details

#initialize(file_path, threshold = 5) ⇒ FileCountThreshold

Returns a new instance of FileCountThreshold.



5
6
7
8
# File 'lib/hiatus/extras/file_count_threshold.rb', line 5

def initialize(file_path, threshold = 5)
  @file_path = file_path
  super threshold
end

Instance Method Details

#incrementObject



10
11
12
13
# File 'lib/hiatus/extras/file_count_threshold.rb', line 10

def increment
  super
  serialize
end

#reached?Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/hiatus/extras/file_count_threshold.rb', line 15

def reached?
  failure_count, threshold = *deserialize
  failure_count >= threshold
end

#resetObject



20
21
22
23
# File 'lib/hiatus/extras/file_count_threshold.rb', line 20

def reset
  super
  serialize
end