class Flame::Dispatcher::Static::StaticFile

Class for static files with helpers methods

Public Class Methods

new(filename, dir) click to toggle source
# File lib/flame/dispatcher/static.rb, line 30
def initialize(filename, dir)
        @filename = filename.to_s
        @path = File.join dir, URI.decode(@filename)
end

Public Instance Methods

content() click to toggle source
# File lib/flame/dispatcher/static.rb, line 51
def content
        File.read(@path)
end
exist?() click to toggle source
# File lib/flame/dispatcher/static.rb, line 35
def exist?
        File.exist?(@path) && File.file?(@path)
end
extname() click to toggle source
# File lib/flame/dispatcher/static.rb, line 43
def extname
        File.extname(@path)
end
mtime() click to toggle source
# File lib/flame/dispatcher/static.rb, line 39
def mtime
        File.mtime(@path)
end
newer?(http_since) click to toggle source
# File lib/flame/dispatcher/static.rb, line 47
def newer?(http_since)
        http_since && Time.httpdate(http_since).to_i >= mtime.to_i
end
path(with_version: false) click to toggle source
# File lib/flame/dispatcher/static.rb, line 55
def path(with_version: false)
        path = @filename
        with_version ? "#{path}?v=#{mtime.to_i}" : path
end