Class: FileWatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/asset_watcher/filewatcher_ext.rb

Instance Method Summary collapse

Instance Method Details

#file_updated?Boolean

Returns:

  • (Boolean)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/asset_watcher/filewatcher_ext.rb', line 2

def file_updated?
  @filenames.each do |filename|
    # Wait for the file's update.
    while not File.exist? filename
      puts "'#{filename}' is not found!"
      sleep 0.5 
    end 

    mtime = File.stat(filename).mtime
    updated = @last_mtimes[filename] < mtime
    @last_mtimes[filename] = mtime
    if(updated)
      @updated_file = filename
      return true
    end 
  end 
  return false
end