Sha256: df3365a29f14ff68b943074f4efd7afc2f358daa1a2022207164dbd46843de10
Contents?: true
Size: 900 Bytes
Versions: 3
Compression:
Stored size: 900 Bytes
Contents
module SimpleView class FileContent NO_READ = :no_read attr_accessor :file, :last_modification def initialize(file) self.file = file self.last_modification = File.mtime(self.file) end def content if changed? || @content == NO_READ @content = File.read(self.file) self.last_modification = File.mtime(self.file) end @content end def changed? @content.nil? || (File.mtime(self.file) > self.last_modification) end def file(set_content_no_read = false) if set_content_no_read @content = NO_READ end @file end class << self def files @files ||= {} end def file(file) return nil unless file self.files[file] ||= self.new(file) end def changed?(file) self.file(file).changed? end end end end
Version data entries
3 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple_view-0.0.2 | lib/simple_view/file_content.rb |
simple_view-0.0.1 | lib/simple_view/CVS/RevisionCache/file_content.rb#1.1.1.1 |
simple_view-0.0.1 | lib/simple_view/file_content.rb |