Module: Sinatra::Mars::Images
- Defined in:
- lib/mars/images.rb
Class Method Summary collapse
-
.registered(app) ⇒ Object
register app.
Instance Method Summary collapse
-
#get_image_type(image_name) ⇒ Object
get image.
Class Method Details
.registered(app) ⇒ Object
register app
5 6 7 8 9 10 11 12 13 |
# File 'lib/mars/images.rb', line 5 def self.registered(app) # stream images app.get %r{(.gif|.jpg|.png|.jpeg)$} do content_type get_image_type(request.path_info) File.open(.views + request.path_info, 'rb') do |file| file.read end end end |
Instance Method Details
#get_image_type(image_name) ⇒ Object
get image
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mars/images.rb', line 16 def get_image_type(image_name) if image_name =~ /.gif/ "image/gif" elsif image_name =~ /.jpg/ "image/jpg" elsif image_name =~ /.png/ "image/png" elsif image_name =~ /.jpeg/ "image/jpeg" end end |