class Sinatra::Reloader::Watcher
Watches a file so it can tell when it has been updated, and what elements does it contain.
Attributes
Public Class Methods
Source
# File lib/sinatra/reloader.rb, line 175 def initialize(path) @ignore = nil @path = path @elements = [] update end
Creates a new Watcher
instance for the file located at path
.
Public Instance Methods
Source
# File lib/sinatra/reloader.rb, line 200 def ignore @ignore = true end
Informs that the modifications to the file being watched should be ignored.
Source
# File lib/sinatra/reloader.rb, line 206 def ignore? !!@ignore end
Indicates whether or not the modifications to the file being watched should be ignored.
Source
# File lib/sinatra/reloader.rb, line 194 def inline_templates? elements.any? { |element| element.type == :inline_templates } end
Indicates whether or not the file being watched has inline templates.
Source
# File lib/sinatra/reloader.rb, line 211 def removed? !File.exist?(path) end
Indicates whether or not the file being watched has been removed.
Source
# File lib/sinatra/reloader.rb, line 188 def update @mtime = File.mtime(path) end
Updates the mtime of the file being watched.
Source
# File lib/sinatra/reloader.rb, line 183 def updated? !ignore? && !removed? && mtime != File.mtime(path) end
Indicates whether or not the file being watched has been modified.