Class: Vectory::Conversion::Strategy Abstract
- Inherits:
-
Object
- Object
- Vectory::Conversion::Strategy
- Defined in:
- lib/vectory/conversion/strategy.rb
Overview
This class is abstract.
Subclasses must implement the #convert method
Base class for conversion strategies
Conversion strategies encapsulate the logic for converting between different vector formats using external tools (Inkscape, Ghostscript, etc.)
Direct Known Subclasses
Instance Method Summary collapse
-
#available? ⇒ Boolean
Check if the required external tool is available.
-
#convert(content, input_format:, output_format:, **options) ⇒ String
abstract
Convert content from one format to another.
-
#supported_conversions ⇒ Array<Array<Symbol>>
Get the list of conversions this strategy supports.
-
#supports?(input_format, output_format) ⇒ Boolean
Check if this strategy supports the given conversion.
-
#tool_name ⇒ String
Get the name of the external tool used by this strategy.
Instance Method Details
#available? ⇒ Boolean
Check if the required external tool is available
45 46 47 48 |
# File 'lib/vectory/conversion/strategy.rb', line 45 def available? raise NotImplementedError, "#{self.class} must implement #available? method" end |
#convert(content, input_format:, output_format:, **options) ⇒ String
This method is abstract.
Convert content from one format to another
21 22 23 24 |
# File 'lib/vectory/conversion/strategy.rb', line 21 def convert(content, input_format:, output_format:, **) raise NotImplementedError, "#{self.class} must implement #convert method" end |
#supported_conversions ⇒ Array<Array<Symbol>>
Get the list of conversions this strategy supports
38 39 40 |
# File 'lib/vectory/conversion/strategy.rb', line 38 def supported_conversions [] end |
#supports?(input_format, output_format) ⇒ Boolean
Check if this strategy supports the given conversion
31 32 33 |
# File 'lib/vectory/conversion/strategy.rb', line 31 def supports?(input_format, output_format) supported_conversions.include?([input_format, output_format]) end |
#tool_name ⇒ String
Get the name of the external tool used by this strategy
53 54 55 |
# File 'lib/vectory/conversion/strategy.rb', line 53 def tool_name self.class.name.split("::").last.gsub(/Strategy$/, "").downcase end |