Class: Lutaml::UmlRepository::Presenters::AssociationPresenter

Inherits:
ElementPresenter
  • Object
show all
Defined in:
lib/lutaml/uml_repository/presenters/association_presenter.rb

Overview

Presenter for UML Association elements.

Formats association information including source, target, and roles.

Instance Attribute Summary

Attributes inherited from ElementPresenter

#context, #element, #repository

Instance Method Summary collapse

Constructor Details

#initialize(element, repository = nil, context = nil) ⇒ AssociationPresenter

Returns a new instance of AssociationPresenter.



13
14
15
# File 'lib/lutaml/uml_repository/presenters/association_presenter.rb', line 13

def initialize(element, repository = nil, context = nil)
  super
end

Instance Method Details

#to_hashObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/lutaml/uml_repository/presenters/association_presenter.rb', line 40

def to_hash
  data = {
    type: "Association",
    name: element.name,
    source: source_display,
    target: target_display,
  }

  data[:xmi_id] = element.xmi_id if element.xmi_id

  data
end

#to_table_rowObject



32
33
34
35
36
37
38
# File 'lib/lutaml/uml_repository/presenters/association_presenter.rb', line 32

def to_table_row
  {
    type: "Association",
    name: element.name || "(unnamed)",
    details: "#{source_display}#{target_display}",
  }
end

#to_textObject

rubocop:disable Metrics/AbcSize,Metrics/MethodLength



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/lutaml/uml_repository/presenters/association_presenter.rb', line 17

def to_text # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
  lines = []
  lines << "Association: #{element.name || '(unnamed)'}"
  lines << ("=" * 50)
  lines << ""
  lines << "Name:          #{element.name || '(unnamed)'}"
  if element.xmi_id
    lines << "XMI ID:        #{element.xmi_id}"
  end
  lines << ""
  lines << "Source:        #{source_display}"
  lines << "Target:        #{target_display}"
  lines.join("\n")
end