Sha256: 45f2a8c33aedef717a44368e872cc29ac5ebf1b69d7fac1601ac0e9cc1dc85bd
Contents?: true
Size: 673 Bytes
Versions: 5
Compression:
Stored size: 673 Bytes
Contents
module Guard class Polling < Listener attr_reader :callback, :latency def initialize super @latency = 1.5 end def on_change(&callback) @callback = callback end def start @stop = false watch_change end def stop @stop = true end private def watch_change while !@stop start = Time.now.to_f files = modified_files([Dir.pwd + '/'], :all => true) update_last_event callback.call(files) unless files.empty? nap_time = latency - (Time.now.to_f - start) sleep(nap_time) if nap_time > 0 end end end end
Version data entries
5 entries across 5 versions & 2 rubygems