Class: DragonflySvg::Analysers::AspectRatioAnalyser

Inherits:
Base
  • Object
show all
Defined in:
lib/dragonfly_svg/analysers/aspect_ratio_analyser.rb

Instance Method Summary collapse

Methods inherited from Base

#is_svg?

Constructor Details

#initialize(app) ⇒ AspectRatioAnalyser

Returns a new instance of AspectRatioAnalyser.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/dragonfly_svg/analysers/aspect_ratio_analyser.rb', line 4

def initialize(app)
  original = app.analysers.items[:aspect_ratio]
  app.add_analyser(:aspect_ratio) do |content|
    if is_svg?(content)
      attrs = content.analyse(:svg_properties)
      attrs[:width].to_f / attrs[:height]
    elsif original
      original.call(content)
    end
  end
end