Class: Cambium::Document
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cambium::Document
- Extended by:
- Dragonfly::Model
- Includes:
- PgSearch
- Defined in:
- app/models/cambium/document.rb
Instance Method Summary collapse
- #ext ⇒ Object
- #has_thumb? ⇒ Boolean
- #image? ⇒ Boolean
- #image_url(width, height) ⇒ Object
- #pdf? ⇒ Boolean
- #png_cover_image_url(width, height) ⇒ Object
- #thumb_url ⇒ Object
-
#to_s ⇒ Object
—————————————— Instance Methods.
Instance Method Details
#ext ⇒ Object
56 57 58 |
# File 'app/models/cambium/document.rb', line 56 def ext upload.ext end |
#has_thumb? ⇒ Boolean
37 38 39 |
# File 'app/models/cambium/document.rb', line 37 def has_thumb? thumb_url.present? end |
#image? ⇒ Boolean
29 30 31 |
# File 'app/models/cambium/document.rb', line 29 def image? ['jpg','jpeg','gif','png'].include?(upload.ext.downcase) end |
#image_url(width, height) ⇒ Object
47 48 49 |
# File 'app/models/cambium/document.rb', line 47 def image_url(width, height) upload.thumb("#{width}x#{height}##{upload_gravity}").url end |
#pdf? ⇒ Boolean
33 34 35 |
# File 'app/models/cambium/document.rb', line 33 def pdf? upload.ext.downcase == 'pdf' end |
#png_cover_image_url(width, height) ⇒ Object
51 52 53 54 |
# File 'app/models/cambium/document.rb', line 51 def png_cover_image_url(width, height) upload.thumb("#{width}x#{height}##{upload_gravity}", :format => 'png', :frame => 0).url end |
#thumb_url ⇒ Object
41 42 43 44 45 |
# File 'app/models/cambium/document.rb', line 41 def thumb_url return image_url(300, 300) return png_cover_image_url(300, 300) if pdf? nil end |
#to_s ⇒ Object
—————————————— Instance Methods
25 26 27 |
# File 'app/models/cambium/document.rb', line 25 def to_s title end |