Class: Lutaml::Xsd::Formatters::FormatterFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/xsd/formatters/formatter_factory.rb

Overview

Factory for creating formatter instances Provides a centralized way to create formatters based on format strings. Uses Registry internally for dynamic formatter registration.

Class Method Summary collapse

Class Method Details

.create(format) ⇒ Base

Create a formatter instance for the specified format

Parameters:

  • format (String)

    The format name (text, json, or yaml)

Returns:

  • (Base)

    A formatter instance

Raises:

  • (ArgumentError)

    If the format is unknown



27
28
29
# File 'lib/lutaml/xsd/formatters/formatter_factory.rb', line 27

def create(format)
  @registry.create(format)
end

.register(name, formatter_class) ⇒ void

This method returns an undefined value.

Register a new formatter class This allows runtime registration of custom formatters

Parameters:

  • name (String, Symbol)

    The format name

  • formatter_class (Class)

    The formatter class

Raises:

  • (ArgumentError)

    If formatter_class doesn’t inherit from Base



53
54
55
# File 'lib/lutaml/xsd/formatters/formatter_factory.rb', line 53

def register(name, formatter_class)
  @registry.register(name, formatter_class)
end

.registryRegistry

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Access the internal registry (for testing or advanced usage)

Returns:

  • (Registry)

    The internal registry instance



61
62
63
# File 'lib/lutaml/xsd/formatters/formatter_factory.rb', line 61

def registry
  @registry
end

.supported?(format) ⇒ Boolean

Check if a format is supported

Parameters:

  • format (String)

    The format name to check

Returns:

  • (Boolean)

    True if the format is supported



42
43
44
# File 'lib/lutaml/xsd/formatters/formatter_factory.rb', line 42

def supported?(format)
  @registry.supported?(format)
end

.supported_formatsArray<String>

Get list of supported format names

Returns:

  • (Array<String>)

    Array of supported format names



34
35
36
# File 'lib/lutaml/xsd/formatters/formatter_factory.rb', line 34

def supported_formats
  @registry.supported_formats
end