module Shrine::Plugins::StoreDimensions::ClassMethods

  1. lib/shrine/plugins/store_dimensions.rb

Public Instance methods

dimensions_analyzer (name)

Returns callable dimensions analyzer object.

[show source]
# File lib/shrine/plugins/store_dimensions.rb, line 96
def dimensions_analyzer(name)
  DimensionsAnalyzer.new(name).method(:call)
end
dimensions_analyzers ()

Returns a hash of built-in dimensions analyzers, where keys are analyzer names and values are #call-able objects which accepts the IO object.

[show source]
# File lib/shrine/plugins/store_dimensions.rb, line 89
def dimensions_analyzers
  @dimensions_analyzers ||= DimensionsAnalyzer::SUPPORTED_TOOLS.inject({}) do |hash, tool|
    hash.merge!(tool => dimensions_analyzer(tool))
  end
end
extract_dimensions (io)

Determines the dimensions of the IO object by calling the specified analyzer.

[show source]
# File lib/shrine/plugins/store_dimensions.rb, line 75
def extract_dimensions(io)
  analyzer = opts[:dimensions_analyzer]
  analyzer = dimensions_analyzer(analyzer) if analyzer.is_a?(Symbol)
  args = [io, dimensions_analyzers].take(analyzer.arity.abs)

  dimensions = analyzer.call(*args)
  io.rewind

  dimensions
end