Class: Middleman::Svg::TransformPipeline::Transformations::Transformation
- Inherits:
-
Object
- Object
- Middleman::Svg::TransformPipeline::Transformations::Transformation
- Defined in:
- lib/middleman/svg/transform_pipeline/transformations/transformation.rb
Direct Known Subclasses
AriaAttributes, AriaHidden, AriaHiddenAttribute, ClassAttribute, DataAttributes, Description, Height, IdAttribute, NoComment, NoDefs, NullTransformation, PreserveAspectRatio, Size, StyleAttribute, Title, Width
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value) ⇒ Transformation
constructor
A new instance of Transformation.
- #transform ⇒ Object
-
#with_svg(doc) {|svg| ... } ⇒ Object
Parses a document and yields the contained SVG nodeset to the given block if it exists.
Constructor Details
#initialize(value) ⇒ Transformation
Returns a new instance of Transformation.
12 13 14 |
# File 'lib/middleman/svg/transform_pipeline/transformations/transformation.rb', line 12 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/middleman/svg/transform_pipeline/transformations/transformation.rb', line 10 def value @value end |
Class Method Details
.create_with_value(value) ⇒ Object
6 7 8 |
# File 'lib/middleman/svg/transform_pipeline/transformations/transformation.rb', line 6 def self.create_with_value(value) self.new(value) end |
Instance Method Details
#transform ⇒ Object
16 17 18 |
# File 'lib/middleman/svg/transform_pipeline/transformations/transformation.rb', line 16 def transform(*) raise "#transform should be implemented by subclasses of Transformation" end |
#with_svg(doc) {|svg| ... } ⇒ Object
Parses a document and yields the contained SVG nodeset to the given block if it exists.
Returns a Nokogiri::XML::Document.
24 25 26 27 28 29 30 31 |
# File 'lib/middleman/svg/transform_pipeline/transformations/transformation.rb', line 24 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 |