Class: DragonflySvg::Analysers::PortraitAnalyser

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

Instance Method Summary collapse

Methods inherited from Base

#is_svg?

Constructor Details

#initialize(app) ⇒ PortraitAnalyser

Returns a new instance of PortraitAnalyser.



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

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