Module: Ea::Svg::EaEmitter::VisibilitySymbol

Defined in:
lib/ea/svg/ea_emitter/visibility_symbol.rb

Overview

Maps UML visibility strings to EA's single-character symbols.

Centralised so that adding a new visibility level (e.g. "implementation" in Java) changes one hash entry, not three case/when branches across separate renderer files.

EA's convention:

+  public
-  private
#  protected
~  package

Constant Summary collapse

SYMBOLS =
{
  "public" => "+",
  "private" => "-",
  "protected" => "#",
  "package" => "~"
}.freeze

Class Method Summary collapse

Class Method Details

.for(visibility, with_space: false) ⇒ String

Returns the UML visibility symbol.

Parameters:

  • visibility (String, nil)

    EA scope string ("Public", "Private", etc.). Case-insensitive; nil defaults to public.

  • with_space (Boolean) (defaults to: false)

    append a trailing space (used by operation renderers: "+ method", not "+method").

Returns:

  • (String)

    the UML visibility symbol



30
31
32
33
# File 'lib/ea/svg/ea_emitter/visibility_symbol.rb', line 30

def self.for(visibility, with_space: false)
  symbol = SYMBOLS[(visibility || "public").downcase] || "+"
  with_space ? "#{symbol} " : symbol
end