Class: File

Inherits:
Object show all
Defined in:
lib/serverside/http/static.rb

Class Method Summary collapse

Class Method Details

.etag(fn) ⇒ Object

Returns an Apache-style ETag for the specified file.



78
79
80
81
# File 'lib/serverside/http/static.rb', line 78

def self.etag(fn)
  stat = File.stat(fn)
  "#{stat.mtime.to_i.to_s(16)}-#{stat.size.to_s(16)}-#{stat.ino.to_s(16)}"
end

.extension(fn) ⇒ Object

Returns the extension for the file name as a symbol.



84
85
86
# File 'lib/serverside/http/static.rb', line 84

def self.extension(fn)
  (ext = (fn =~ /\.([^\.\/]+)$/) && $1) ? ext.to_sym : nil
end