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.



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

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

Instance Method Details

#check(value) ⇒ Object



20
21
22
23
# File 'lib/bluepill/process_conditions/file_time.rb', line 20

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

#run(pid, include_children) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/bluepill/process_conditions/file_time.rb', line 10

def run(pid, include_children)
  if File.exists?(@filename)
    Time.now()-File::mtime(@filename)
  else
    nil
  end
rescue
  $!
end