Class: Cambium::Document

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
Dragonfly::Model
Includes:
PgSearch
Defined in:
app/models/cambium/document.rb

Instance Method Summary collapse

Instance Method Details

#extObject



56
57
58
# File 'app/models/cambium/document.rb', line 56

def ext
  upload.ext
end

#has_thumb?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/models/cambium/document.rb', line 37

def has_thumb?
  thumb_url.present?
end

#image?Boolean

Returns:

  • (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

Returns:

  • (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_urlObject



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_sObject

—————————————— Instance Methods



25
26
27
# File 'app/models/cambium/document.rb', line 25

def to_s
  title
end