Class: DynamicImage::Picture::FormatPolicy
- Inherits:
-
Object
- Object
- DynamicImage::Picture::FormatPolicy
- Defined in:
- lib/dynamic_image/picture/format_policy.rb
Overview
DynamicImage Picture Format Policy
Decides what a responsive image is rendered in. The source gets the best format available for output, transcoded unconditionally. The img gets one of COMPATIBLE_FORMATS.
Constant Summary collapse
- DEFAULT_SOURCE_FORMAT =
The format the candidates are rendered in when the view doesn't ask for one.
:webp
Instance Attribute Summary collapse
- #record ⇒ DynamicImage::Model readonly
-
#requested ⇒ Object
readonly
Returns the value of attribute requested.
Instance Method Summary collapse
-
#fallback ⇒ DynamicImage::Format
The format the fallback image is rendered in.
-
#initialize(record, requested = nil) ⇒ FormatPolicy
constructor
A new instance of FormatPolicy.
-
#source ⇒ DynamicImage::Format
The format the candidates are rendered in.
Constructor Details
#initialize(record, requested = nil) ⇒ FormatPolicy
Returns a new instance of FormatPolicy.
24 25 26 27 |
# File 'lib/dynamic_image/picture/format_policy.rb', line 24 def initialize(record, requested = nil) @record = record @requested = requested end |
Instance Attribute Details
#record ⇒ DynamicImage::Model (readonly)
19 20 21 |
# File 'lib/dynamic_image/picture/format_policy.rb', line 19 def record @record end |
#requested ⇒ Object (readonly)
Returns the value of attribute requested.
19 |
# File 'lib/dynamic_image/picture/format_policy.rb', line 19 attr_reader :record, :requested |
Instance Method Details
#fallback ⇒ DynamicImage::Format
The format the fallback image is rendered in.
39 40 41 |
# File 'lib/dynamic_image/picture/format_policy.rb', line 39 def fallback @fallback ||= resolve(fallback_formats) end |
#source ⇒ DynamicImage::Format
The format the candidates are rendered in.
32 33 34 |
# File 'lib/dynamic_image/picture/format_policy.rb', line 32 def source @source ||= resolve(requested || default_source) end |