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