Module: DrawioDsl::Formatters::Factory

Includes:
KLog::Logging
Included in:
Schema::Shape
Defined in:
lib/drawio_dsl/formatters/factory.rb

Overview

Create an instance of a HTML formatter on the shape

Constant Summary collapse

FORMATTERS =
{
  klass: DrawioDsl::Formatters::KlassFormatter,
  class: DrawioDsl::Formatters::KlassFormatter, # alias for klass
  interface: DrawioDsl::Formatters::InterfaceFormatter
}.freeze

Instance Method Summary collapse

Instance Method Details

#format_instance(type) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/drawio_dsl/formatters/factory.rb', line 17

def format_instance(type)
  unless FORMATTERS.key?(type)
    log.error "Unknown formatter type: #{type}"
    @formatter = nil
    return formatter
  end

  @formatter = FORMATTERS[type].new
  formatter
end

#formatterObject



28
29
30
# File 'lib/drawio_dsl/formatters/factory.rb', line 28

def formatter
  @formatter ||= DrawioDsl::Formatters::BaseFormatter.new
end