Class: Puppet::Util::Watcher::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/watcher/timer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(timeout) ⇒ Timer

Returns a new instance of Timer.



6
7
8
# File 'lib/puppet/util/watcher/timer.rb', line 6

def initialize(timeout)
  @timeout = timeout
end

Instance Attribute Details

#timeoutObject (readonly)

Returns the value of attribute timeout.



4
5
6
# File 'lib/puppet/util/watcher/timer.rb', line 4

def timeout
  @timeout
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/puppet/util/watcher/timer.rb', line 14

def expired?
  (now - @start_time) >= @timeout
end

#nowObject



18
19
20
# File 'lib/puppet/util/watcher/timer.rb', line 18

def now
  Time.now.to_i
end

#startObject



10
11
12
# File 'lib/puppet/util/watcher/timer.rb', line 10

def start
  @start_time = now
end