module Shrine::Plugins::StoreDimensions::ClassMethods
Public Instance Methods
Source
# File lib/shrine/plugins/store_dimensions.rb 57 def dimensions_analyzer(name) 58 on_error = opts[:store_dimensions][:on_error] 59 60 DimensionsAnalyzer.new(name, on_error:).method(:call) 61 end
Returns callable dimensions analyzer object.
Source
# File lib/shrine/plugins/store_dimensions.rb 50 def dimensions_analyzers 51 @dimensions_analyzers ||= DimensionsAnalyzer::SUPPORTED_TOOLS.inject({}) do |hash, tool| 52 hash.merge!(tool => dimensions_analyzer(tool)) 53 end 54 end
Returns a hash of built-in dimensions analyzers, where keys are analyzer names and values are #call-able objects which accepts the IO object.
Source
# File lib/shrine/plugins/store_dimensions.rb 35 def extract_dimensions(io) 36 analyzer = opts[:store_dimensions][:analyzer] 37 analyzer = dimensions_analyzer(analyzer) if analyzer.is_a?(Symbol) 38 args = [io, dimensions_analyzers].take(analyzer.arity.abs) 39 40 dimensions = instrument_dimensions(io) { analyzer.call(*args) } 41 io.rewind 42 43 dimensions 44 end
Determines the dimensions of the IO object by calling the specified analyzer.
Also aliased as: dimensions