Module: ScribdFu::Paperclip::InstanceMethods
- Defined in:
- lib/scribd_fu/paperclip.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#file_path ⇒ Object
Returns the full filename for the given attribute.
-
#get_content_type ⇒ Object
Find the content type of the associated file.
-
#thumbnail_url ⇒ Object
Returns a URL for a thumbnail for the specified
attributeattachment.
Class Method Details
.included(base) ⇒ Object
9 10 11 |
# File 'lib/scribd_fu/paperclip.rb', line 9 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#file_path ⇒ Object
Returns the full filename for the given attribute. If the file is stored on S3, this is a full S3 URI, while it is a full path to the local file if the file is stored locally.
37 38 39 40 41 42 43 |
# File 'lib/scribd_fu/paperclip.rb', line 37 def file_path if attached_file.url =~ /^https{0,1}:\/\/s3.amazonaws.com$/ attached_file.url else attached_file.path end end |
#get_content_type ⇒ Object
Find the content type of the associated file
14 15 16 |
# File 'lib/scribd_fu/paperclip.rb', line 14 def get_content_type self.send("#{prefix}_content_type") end |
#thumbnail_url ⇒ Object
Returns a URL for a thumbnail for the specified attribute attachment.
If Scribd does not provide a thumbnail URL, then Paperclip’s thumbnail is fallen back on by returning the value of attribute.url(:thumb).
Sample use in a view:
<%= image_tag(@attachment.thumbnail_url, :alt => @attachment.name) %>
26 27 28 29 30 31 32 |
# File 'lib/scribd_fu/paperclip.rb', line 26 def thumbnail_url begin (ipaper_document && ipaper_document.thumbnail_url) || attached_file.url(:thumb) rescue raise ScribdFu::ScribdFuError, "The thumbnail doesn't exist." end end |