Class: Bluepill::ProcessConditions::FileTime

Inherits:
ProcessCondition show all
Defined in:
lib/bluepill/process_conditions/file_time.rb

Instance Method Summary collapse

Methods inherited from ProcessCondition

#format_value

Constructor Details

#initialize(options = {}) ⇒ FileTime

Returns a new instance of FileTime.



4
5
6
7
# File 'lib/bluepill/process_conditions/file_time.rb', line 4

def initialize(options = {})
  @below = options[:below]
  @filename = options[:filename]
end

Instance Method Details

#check(value) ⇒ Object



15
16
17
18
# File 'lib/bluepill/process_conditions/file_time.rb', line 15

def check(value)
  return false if value.nil?
  value < @below
end

#run(_pid, _include_children) ⇒ Object



9
10
11
12
13
# File 'lib/bluepill/process_conditions/file_time.rb', line 9

def run(_pid, _include_children)
  Time.now - File.mtime(@filename) if File.exist?(@filename)
rescue
  $ERROR_INFO
end