Class: Cambium::Document

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

Instance Method Summary collapse

Instance Method Details

#extObject



54
55
56
# File 'app/models/cambium/document.rb', line 54

def ext
  upload.ext
end

#has_thumb?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'app/models/cambium/document.rb', line 35

def has_thumb?
  thumb_url.present?
end

#image?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/models/cambium/document.rb', line 27

def image?
  ['jpg','jpeg','gif','png'].include?(upload.ext.downcase)
end

#image_url(width, height) ⇒ Object



45
46
47
# File 'app/models/cambium/document.rb', line 45

def image_url(width, height)
  upload.thumb("#{width}x#{height}##{upload_gravity}").url
end

#pdf?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/cambium/document.rb', line 31

def pdf?
  upload.ext.downcase == 'pdf'
end

#png_cover_image_url(width, height) ⇒ Object



49
50
51
52
# File 'app/models/cambium/document.rb', line 49

def png_cover_image_url(width, height)
  upload.thumb("#{width}x#{height}##{upload_gravity}", :format => 'png',
               :frame => 0).url
end

#thumb_urlObject



39
40
41
42
43
# File 'app/models/cambium/document.rb', line 39

def thumb_url
  return image_url(300, 300)
  return png_cover_image_url(300, 300) if pdf?
  nil
end

#to_sObject

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



23
24
25
# File 'app/models/cambium/document.rb', line 23

def to_s
  title
end