2019-08-06 17:54:17 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Define un campo de imagen
|
2019-11-07 16:08:14 +00:00
|
|
|
class MetadataImage < MetadataFile
|
2019-08-22 19:13:21 +00:00
|
|
|
def validate
|
|
|
|
super
|
|
|
|
|
2019-08-23 18:24:41 +00:00
|
|
|
errors << I18n.t('metadata.image.not_an_image') unless image?
|
2019-08-22 19:13:21 +00:00
|
|
|
|
|
|
|
errors.compact!
|
|
|
|
errors.empty?
|
|
|
|
end
|
|
|
|
|
2020-08-05 15:29:11 +00:00
|
|
|
# Determina si es una imagen
|
2019-08-23 18:24:41 +00:00
|
|
|
def image?
|
2020-08-07 14:15:06 +00:00
|
|
|
filemagic.file(file).starts_with? 'image/'
|
2019-08-23 18:24:41 +00:00
|
|
|
end
|
2019-08-06 17:54:17 +00:00
|
|
|
end
|