Class: Shrine::Plugins::StoreDimensions::DimensionsAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/shrine/plugins/store_dimensions.rb

Constant Summary collapse

SUPPORTED_TOOLS =
[:fastimage, :mini_magick, :ruby_vips]

Instance Method Summary collapse

Constructor Details

#initialize(tool, on_error: method(:fail)) ⇒ DimensionsAnalyzer

Returns a new instance of DimensionsAnalyzer.

Raises:


101
102
103
104
105
106
# File 'lib/shrine/plugins/store_dimensions.rb', line 101

def initialize(tool, on_error: method(:fail))
  raise Error, "unknown dimensions analyzer #{tool.inspect}, supported analyzers are: #{SUPPORTED_TOOLS.join(",")}" unless SUPPORTED_TOOLS.include?(tool)

  @tool     = tool
  @on_error = on_error
end

Instance Method Details

#call(io) ⇒ Object


108
109
110
111
112
# File 'lib/shrine/plugins/store_dimensions.rb', line 108

def call(io)
  dimensions = send(:"extract_with_#{@tool}", io)
  io.rewind
  dimensions
end