Class: DerivedImages::FormatSupport
- Inherits:
-
Object
- Object
- DerivedImages::FormatSupport
- Defined in:
- lib/derived_images/format_support.rb
Overview
A helper class to test for library support for different image formats.
Constant Summary collapse
- KNOWN_FORMATS =
%w[bmp gif jpg png webp avif heic jp2 jxl].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(processor = DerivedImages.config.processor) ⇒ FormatSupport
constructor
A new instance of FormatSupport.
- #supports?(format) ⇒ Boolean
Constructor Details
#initialize(processor = DerivedImages.config.processor) ⇒ FormatSupport
Returns a new instance of FormatSupport.
8 9 10 |
# File 'lib/derived_images/format_support.rb', line 8 def initialize(processor = DerivedImages.config.processor) @processor = processor end |
Class Method Details
.table(processor) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/derived_images/format_support.rb', line 29 def self.table(processor) instance = new(processor) %w[BMP GIF JPEG PNG TIFF WebP].map { [_1, true] }.tap do |table| table << ['AVIF', instance.avif?] table << ['HEIC', instance.heic?] table << ['JPEG 2000', instance.jpeg_2000?] table << ['JPEG XL', instance.jpeg_xl?] end end |
Instance Method Details
#supports?(format) ⇒ Boolean
19 20 21 22 23 24 25 26 27 |
# File 'lib/derived_images/format_support.rb', line 19 def supports?(format) if processor == :vips vips.include?(format) elsif processor == :mini_magick magick.include?(format) else raise "Unknown processor #{processor}" end end |