Class: Decidim::Attachment
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Attachment
- Defined in:
- app/models/decidim/attachment.rb
Overview
Attachment can be any type of document or images related to a partcipatory process.
Instance Method Summary collapse
-
#big_url ⇒ Object
The URL to download the a big version of the file.
-
#document? ⇒ Boolean
Whether this attachment is a document or not.
-
#file_type ⇒ Object
Which kind of file this is.
-
#photo? ⇒ Boolean
Whether this attachment is a photo or not.
-
#thumbnail_url ⇒ Object
The URL to download the thumbnail of the file.
Instance Method Details
#big_url ⇒ Object
The URL to download the a big version of the file. Only works with images.
Returns String.
50 51 52 53 |
# File 'app/models/decidim/attachment.rb', line 50 def big_url return unless photo? file.big.url end |
#document? ⇒ Boolean
Whether this attachment is a document or not.
Returns Boolean.
23 24 25 |
# File 'app/models/decidim/attachment.rb', line 23 def document? !photo? end |
#file_type ⇒ Object
Which kind of file this is.
Returns String.
30 31 32 |
# File 'app/models/decidim/attachment.rb', line 30 def file_type file.url&.split(".")&.last&.downcase end |
#photo? ⇒ Boolean
Whether this attachment is a photo or not.
Returns Boolean.
16 17 18 |
# File 'app/models/decidim/attachment.rb', line 16 def photo? @photo ||= content_type.start_with? "image" end |
#thumbnail_url ⇒ Object
The URL to download the thumbnail of the file. Only works with images.
Returns String.
42 43 44 45 |
# File 'app/models/decidim/attachment.rb', line 42 def thumbnail_url return unless photo? file.thumbnail.url end |