Sha256: f1bcac598397aba844e7dc4218a088099c768d8c55a04ecffc541a1f472e9431

Contents?: true

Size: 551 Bytes

Versions: 3

Compression:

Stored size: 551 Bytes

Contents

require 'nokogiri'

module DragonflySvg
  module Analysers
    class SvgProperties

      def call content
        node = svg_node(content)

        {
          width: node.get_attribute('width').to_f,
          height: node.get_attribute('height').to_f,
          id: node.get_attribute('id'),
        }
      end

      private # =============================================================

      def svg_node content
        return unless doc = Nokogiri::XML(content.data)
        doc.xpath("//*[name()='svg']").first
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dragonfly_svg-0.0.3 lib/dragonfly_svg/analysers/svg_properties.rb
dragonfly_svg-0.0.2 lib/dragonfly_svg/analysers/svg_properties.rb
dragonfly_svg-0.0.1 lib/dragonfly_svg/analysers/svg_properties.rb