class InlineSvg::TransformPipeline::Transformations::Transformation

Attributes

value[R]

Public Class Methods

create_with_value(value) click to toggle source
# File lib/inline_svg/transform_pipeline/transformations/transformation.rb, line 3
def self.create_with_value(value)
  self.new(value)
end
new(value) click to toggle source
# File lib/inline_svg/transform_pipeline/transformations/transformation.rb, line 9
def initialize(value)
  @value = value
end

Public Instance Methods

transform(*) click to toggle source
# File lib/inline_svg/transform_pipeline/transformations/transformation.rb, line 13
def transform(*)
  raise "#transform should be implemented by subclasses of Transformation"
end
with_svg(doc) { |svg| ... } click to toggle source

Parses a document and yields the contained SVG nodeset to the given block if it exists.

Returns a Nokogiri::XML::Document.

# File lib/inline_svg/transform_pipeline/transformations/transformation.rb, line 21
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