Class: ServerHere::FileWrapper
- Inherits:
-
Object
- Object
- ServerHere::FileWrapper
- Defined in:
- lib/server_here/file_wrapper.rb
Instance Method Summary collapse
- #content_type ⇒ Object
- #ext ⇒ Object
-
#initialize(file) ⇒ FileWrapper
constructor
A new instance of FileWrapper.
- #last_mod ⇒ Object
- #to_body ⇒ Object
Constructor Details
#initialize(file) ⇒ FileWrapper
Returns a new instance of FileWrapper.
3 4 5 |
# File 'lib/server_here/file_wrapper.rb', line 3 def initialize file @f = file end |
Instance Method Details
#content_type ⇒ Object
15 16 17 |
# File 'lib/server_here/file_wrapper.rb', line 15 def content_type 'text/' + (%w{html css}.include?(ext) ? ext : 'plain') end |
#ext ⇒ Object
11 12 13 |
# File 'lib/server_here/file_wrapper.rb', line 11 def ext File.extname(@f).gsub(/\./, '') end |
#last_mod ⇒ Object
7 8 9 |
# File 'lib/server_here/file_wrapper.rb', line 7 def last_mod @last_mod ||= File.mtime(@f).strftime '%a, %d %b %Y %T GMT' end |
#to_body ⇒ Object
19 20 21 |
# File 'lib/server_here/file_wrapper.rb', line 19 def to_body [File.read(@f)] end |