Sha256: ee66790283171cd5178fe1244a1249d023123b562f647683c07d80a654da34d2

Contents?: true

Size: 558 Bytes

Versions: 2

Compression:

Stored size: 558 Bytes

Contents

# frozen_string_literal: true

module God
  module Conditions
    class FileMtime < PollCondition
      attr_accessor :path, :max_age

      def initialize
        super
        self.path = nil
        self.max_age = nil
      end

      def valid?
        valid = true
        valid &= complain("Attribute 'path' must be specified", self) if path.nil?
        valid &= complain("Attribute 'max_age' must be specified", self) if max_age.nil?
        valid
      end

      def test
        (Time.now - File.mtime(path)) > max_age
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
resurrected_god-1.1.1 lib/god/conditions/file_mtime.rb
resurrected_god-1.1.0 lib/god/conditions/file_mtime.rb