Class: Alchemy::StorageAdapter::Dragonfly::PictureUrl
- Inherits:
-
Object
- Object
- Alchemy::StorageAdapter::Dragonfly::PictureUrl
- Defined in:
- app/models/alchemy/storage_adapter/dragonfly/picture_url.rb
Constant Summary collapse
- TRANSFORMATION_OPTIONS =
[ :crop, :crop_from, :crop_size, :flatten, :format, :quality, :size, :upsample ]
Instance Attribute Summary collapse
-
#picture ⇒ Object
readonly
Returns the value of attribute picture.
-
#thumb ⇒ Object
readonly
Returns the value of attribute thumb.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Instance Method Summary collapse
-
#call(options = {}) ⇒ String
The URL to a variant of a picture.
-
#initialize(picture) ⇒ PictureUrl
constructor
A new instance of PictureUrl.
Constructor Details
#initialize(picture) ⇒ PictureUrl
Returns a new instance of PictureUrl.
21 22 23 |
# File 'app/models/alchemy/storage_adapter/dragonfly/picture_url.rb', line 21 def initialize(picture) @picture = picture end |
Instance Attribute Details
#picture ⇒ Object (readonly)
Returns the value of attribute picture.
17 18 19 |
# File 'app/models/alchemy/storage_adapter/dragonfly/picture_url.rb', line 17 def picture @picture end |
#thumb ⇒ Object (readonly)
Returns the value of attribute thumb.
17 18 19 |
# File 'app/models/alchemy/storage_adapter/dragonfly/picture_url.rb', line 17 def thumb @thumb end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
17 18 19 |
# File 'app/models/alchemy/storage_adapter/dragonfly/picture_url.rb', line 17 def variant @variant end |
Instance Method Details
#call(options = {}) ⇒ String
The URL to a variant of a picture
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/alchemy/storage_adapter/dragonfly/picture_url.rb', line 29 def call( = {}) @variant = PictureVariant.new(picture, .slice(*TRANSFORMATION_OPTIONS)) params = { basename: picture.name, ext: variant.render_format, name: picture.name } return variant.image.url(params) unless processible_image? "/#{uid}" end |