Class: Asset
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Asset
- Defined in:
- app/models/asset.rb
Constant Summary collapse
- AUDIO_FORMATS =
HACK: incomplete
[:wav, :mp3, :m4a, :ogg]
- VIDEO_FORMATS =
[:mp4, :avi]
Instance Method Summary collapse
Instance Method Details
#audio? ⇒ Boolean
26 27 28 |
# File 'app/models/asset.rb', line 26 def audio? AUDIO_FORMATS.include?(format) end |
#format ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'app/models/asset.rb', line 9 def format # HACK: relying on extension instead of using analyser and upload.format # analyser can throw us into very long loop when trying to identify # non-image files like word docs upload.ext && upload.ext.to_sym rescue Dragonfly::FunctionManager::UnableToHandle :generic end |
#image? ⇒ Boolean
18 19 20 21 22 23 24 |
# File 'app/models/asset.rb', line 18 def image? # PDF is listed as supported by imagemagick but thumbnailing etc. doesn't # work reliably so we treat it as a non-image return false if format == :pdf image_formats = Dragonfly::Encoding::ImageMagickEncoder.new.supported_formats image_formats.include?(format) end |
#to_s ⇒ Object
34 35 36 |
# File 'app/models/asset.rb', line 34 def to_s || upload.name end |
#video? ⇒ Boolean
30 31 32 |
# File 'app/models/asset.rb', line 30 def video? VIDEO_FORMATS.include?(format) end |