Sha256: 194685319a96a63f9f264fb94cff7315873147f74157c1f256d42d7cb107a3b4
Contents?: true
Size: 1.12 KB
Versions: 15
Compression:
Stored size: 1.12 KB
Contents
module InlineSvg::TransformPipeline::Transformations class Transformation def self.create_with_value(value) self.new(value) end attr_reader :value def initialize(value) @value = value end def transform(*) raise "#transform should be implemented by subclasses of Transformation" end # Parses a document and yields the contained SVG nodeset to the given block # if it exists. # # Returns a Nokogiri::XML::Document. def with_svg(doc) doc = Nokogiri::XML::Document.parse( doc.to_html(encoding: "UTF-8"), nil, "UTF-8" ) svg = doc.at_css "svg" yield svg if svg && block_given? doc end end class NullTransformation < Transformation def transform(doc) doc end end end module InlineSvg class CustomTransformation < InlineSvg::TransformPipeline::Transformations::Transformation # Inherit from this class to keep custom transformation class definitions short # E.g. # class MyTransform < InlineSvg::CustomTransformation # def transform(doc) # # Your code here... # end # end end end
Version data entries
15 entries across 15 versions & 2 rubygems