Class: Algoheader::PngTransformer
- Inherits:
-
ServiceObject
- Object
- ServiceObject
- Algoheader::PngTransformer
- Defined in:
- lib/algoheader/png_transformer.rb
Overview
PngTransformer
- Author
-
Dick Davis
- Copyright
-
Copyright 2021 Dick Davis
- License
-
GNU Public License 3
Service object that writes SVG blobs to PNG files.
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#svg ⇒ Object
readonly
Returns the value of attribute svg.
Instance Method Summary collapse
-
#call ⇒ Object
rubocop:enable Lint/MissingSuper.
-
#initialize(svg, dir, filename) ⇒ PngTransformer
constructor
rubocop:disable Lint/MissingSuper.
Methods inherited from ServiceObject
Constructor Details
#initialize(svg, dir, filename) ⇒ PngTransformer
rubocop:disable Lint/MissingSuper
35 36 37 38 39 |
# File 'lib/algoheader/png_transformer.rb', line 35 def initialize(svg, dir, filename) @svg = svg @dir = dir @filename = filename end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
32 33 34 |
# File 'lib/algoheader/png_transformer.rb', line 32 def dir @dir end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
32 33 34 |
# File 'lib/algoheader/png_transformer.rb', line 32 def filename @filename end |
#svg ⇒ Object (readonly)
Returns the value of attribute svg.
32 33 34 |
# File 'lib/algoheader/png_transformer.rb', line 32 def svg @svg end |
Instance Method Details
#call ⇒ Object
rubocop:enable Lint/MissingSuper
42 43 44 45 46 47 48 |
# File 'lib/algoheader/png_transformer.rb', line 42 def call img = Magick::Image.from_blob(svg) do self.format = 'SVG' self.background_color = 'transparent' end img[0].write("#{dir}/#{filename}.png") end |