Class: Vectory::Conversion::InkscapeStrategy
- Defined in:
- lib/vectory/conversion/inkscape_strategy.rb
Overview
Inkscape-based conversion strategy
Handles conversions using Inkscape, including:
-
SVG ↔ EPS
-
SVG ↔ PS
-
SVG ↔ EMF
-
SVG ↔ PDF
-
EPS/PS → PDF
Constant Summary collapse
- SUPPORTED_CONVERSIONS =
Inkscape supports bidirectional conversion with SVG as source/target
[ %i[svg eps], %i[svg ps], %i[svg emf], %i[svg pdf], %i[eps svg], %i[eps pdf], %i[ps svg], %i[ps pdf], %i[pdf svg], %i[emf svg], ].freeze
Instance Method Summary collapse
-
#available? ⇒ Boolean
Check if Inkscape is available.
-
#convert(content, input_format:, output_format:, **options) ⇒ Vectory::Vector
Convert content using Inkscape.
-
#height(content, format) ⇒ Integer
Query the height of content.
-
#supported_conversions ⇒ Array<Array<Symbol>>
Get supported conversions.
-
#supports?(input_format, output_format) ⇒ Boolean
Check if this conversion is supported.
-
#tool_name ⇒ String
Get the tool name.
-
#width(content, format) ⇒ Integer
Query the width of content.
Instance Method Details
#available? ⇒ Boolean
Check if Inkscape is available
73 74 75 76 77 78 |
# File 'lib/vectory/conversion/inkscape_strategy.rb', line 73 def available? InkscapeWrapper.instance.send(:inkscape_path) true rescue Vectory::InkscapeNotFoundError false end |
#convert(content, input_format:, output_format:, **options) ⇒ Vectory::Vector
Convert content using Inkscape
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/vectory/conversion/inkscape_strategy.rb', line 40 def convert(content, input_format:, output_format:, **) output_class = .fetch(:output_class) do format_class(output_format) end InkscapeWrapper.convert( content: content, input_format: input_format, output_format: output_format, output_class: output_class, plain: [:plain] || false, ) end |
#height(content, format) ⇒ Integer
Query the height of content
101 102 103 |
# File 'lib/vectory/conversion/inkscape_strategy.rb', line 101 def height(content, format) InkscapeWrapper.instance.height(content, format) end |
#supported_conversions ⇒ Array<Array<Symbol>>
Get supported conversions
66 67 68 |
# File 'lib/vectory/conversion/inkscape_strategy.rb', line 66 def supported_conversions SUPPORTED_CONVERSIONS end |
#supports?(input_format, output_format) ⇒ Boolean
Check if this conversion is supported
59 60 61 |
# File 'lib/vectory/conversion/inkscape_strategy.rb', line 59 def supports?(input_format, output_format) SUPPORTED_CONVERSIONS.include?([input_format, output_format]) end |
#tool_name ⇒ String
Get the tool name
83 84 85 |
# File 'lib/vectory/conversion/inkscape_strategy.rb', line 83 def tool_name "inkscape" end |
#width(content, format) ⇒ Integer
Query the width of content
92 93 94 |
# File 'lib/vectory/conversion/inkscape_strategy.rb', line 92 def width(content, format) InkscapeWrapper.instance.width(content, format) end |