Class: Fontisan::Commands::MultiFormatOutput

Inherits:
Object
  • Object
show all
Defined in:
lib/fontisan/commands/multi_format_output.rb

Overview

Resolves the on-disk output path for each target format in a multi-format conversion (TODO 72).

Rules:

- One format + path has extension → use the path as-is.
- One format + path has no extension → append ".<format>".
- Many formats + path has extension → +ArgumentError+ (ambiguous).
- Many formats + path has no extension → append ".<format>" per target.

Pure value object: no I/O, no mutation. Extracted from ConvertCommand so multi-format path resolution can be tested independently of the transformation pipeline.

Instance Method Summary collapse

Constructor Details

#initialize(base_path, target_formats) ⇒ MultiFormatOutput

Returns a new instance of MultiFormatOutput.

Parameters:

  • base_path (String)

    user-supplied --output value

  • target_formats (Array<Symbol>)

    non-empty, deduplicated



20
21
22
23
# File 'lib/fontisan/commands/multi_format_output.rb', line 20

def initialize(base_path, target_formats)
  @base_path = base_path
  @target_formats = target_formats
end

Instance Method Details

#pathsArray<String>

Returns one resolved path per target format, in the same order as target_formats.

Returns:

  • (Array<String>)

    one resolved path per target format, in the same order as target_formats

Raises:

  • (ArgumentError)

    if the base path is ambiguous



28
29
30
# File 'lib/fontisan/commands/multi_format_output.rb', line 28

def paths
  single? ? [single_format_path] : multi_format_paths
end