Module: ScribdFu::AttachmentFu::InstanceMethods
- Defined in:
- lib/scribd_fu/attachment_fu.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#file_path ⇒ Object
Yields the correct path to the file, either the local filename or the S3 URL.
- #get_content_type ⇒ Object
-
#thumbnail_url ⇒ Object
Returns a URL for a thumbnail for this model’s attachment.
Class Method Details
.included(base) ⇒ Object
9 10 11 |
# File 'lib/scribd_fu/attachment_fu.rb', line 9 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#file_path ⇒ Object
Yields the correct path to the file, either the local filename or the S3 URL.
30 31 32 33 34 35 36 |
# File 'lib/scribd_fu/attachment_fu.rb', line 30 def file_path if public_filename =~ /^https{0,1}:\/\/s3.amazonaws.com/ public_filename else "#{RAILS_ROOT}/public#{public_filename}" end end |
#get_content_type ⇒ Object
25 26 27 |
# File 'lib/scribd_fu/attachment_fu.rb', line 25 def get_content_type self.content_type end |
#thumbnail_url ⇒ Object
Returns a URL for a thumbnail for this model’s attachment.
If Scribd does not provide a thumbnail URL, then Attachment_fu’s thumbnail is fallen back on by returning the value of public_filename(:thumb).
Sample use in a view:
<%= image_tag(@attachment.thumbnail_url, :alt => @attachment.name) %>
21 22 23 |
# File 'lib/scribd_fu/attachment_fu.rb', line 21 def thumbnail_url (ipaper_document && ipaper_document.thumbnail_url) || public_filename(:thumb) end |