Sha256: d69a2f02e6ad0148117612e36fa87b62dcdebad09f31da67862c2727576dc9d2
Contents?: true
Size: 470 Bytes
Versions: 24
Compression:
Stored size: 470 Bytes
Contents
module InlineSvg::TransformPipeline::Transformations class Size < Transformation def transform(doc) doc = Nokogiri::XML::Document.parse(doc.to_html) svg = doc.at_css 'svg' svg['width'] = width_of(self.value) svg['height'] = height_of(self.value) doc end def width_of(value) value.split(/\*/).map(&:strip)[0] end def height_of(value) value.split(/\*/).map(&:strip)[1] || width_of(value) end end end
Version data entries
24 entries across 24 versions & 1 rubygems