Class: Ea::Svg::EaEmitter::Element::EnumerationLiteralRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/svg/ea_emitter/element/enumeration_literal_renderer.rb

Overview

Emits the enumeration literal compartment text <g>. Each literal appears as a separate text element matching EA's encoding:

<text>literal_name</text>

Rendered as a third compartment below the attribute compartment for Enumeration classifiers.

Class Method Summary collapse

Class Method Details

.render(literals, bounds:, first_y:, family:, size:) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/ea/svg/ea_emitter/element/enumeration_literal_renderer.rb', line 16

def self.render(literals, bounds:, first_y:, family:, size:)
  line_h = size + 4
  text_blocks = literals.each_with_index.map do |literal, idx|
    y = first_y + (idx * line_h)
    build_text(bounds.x + 5, y, literal.name.to_s, family, size)
  end
  %(<g style="#{Style::TEXT_GROUP}">\n#{text_blocks.join("\n")}\n</g>)
end