Class: Shutterbug::Storage::FileStorage
- Inherits:
-
Object
- Object
- Shutterbug::Storage::FileStorage
- Defined in:
- lib/shutterbug/storage/file_storage.rb
Constant Summary collapse
- MIME_TYPES =
{ '.png' => 'image/png', '.jpeg' => 'image/jpeg', '.jpg' => 'image/jpeg', '.html' => 'text/html', '' => 'text/html' }
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #get_content ⇒ Object
-
#initialize(filename) ⇒ FileStorage
constructor
A new instance of FileStorage.
- #mime_type ⇒ Object
Constructor Details
#initialize(filename) ⇒ FileStorage
Returns a new instance of FileStorage.
19 20 21 22 |
# File 'lib/shutterbug/storage/file_storage.rb', line 19 def initialize(filename) @filename = Configuration.instance.fs_path_for(filename) @url = self.class.get_url(filename) end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
4 5 6 |
# File 'lib/shutterbug/storage/file_storage.rb', line 4 def filename @filename end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/shutterbug/storage/file_storage.rb', line 5 def url @url end |
Class Method Details
.get_url(name) ⇒ Object
15 16 17 |
# File 'lib/shutterbug/storage/file_storage.rb', line 15 def self.get_url(name) "#{Handlers::FileHandler.uri_prefix}/#{name}" end |
Instance Method Details
#get_content ⇒ Object
24 25 26 |
# File 'lib/shutterbug/storage/file_storage.rb', line 24 def get_content File.open(@filename, 'r') end |
#mime_type ⇒ Object
28 29 30 |
# File 'lib/shutterbug/storage/file_storage.rb', line 28 def mime_type MIME_TYPES[File.extname(@filename)] end |