Class: Lutaml::UmlRepository::Presenters::AssociationPresenter
- Inherits:
-
ElementPresenter
- Object
- ElementPresenter
- Lutaml::UmlRepository::Presenters::AssociationPresenter
- 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
-
#initialize(element, repository = nil, context = nil) ⇒ AssociationPresenter
constructor
A new instance of AssociationPresenter.
- #to_hash ⇒ Object
- #to_table_row ⇒ Object
-
#to_text ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
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_hash ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/lutaml/uml_repository/presenters/association_presenter.rb', line 43 def to_hash data = { type: "Association", name: element.name, source: source_display, target: target_display, } data[:xmi_id] = element.xmi_id if element.respond_to?(:xmi_id) data[:xmi_type] = element.xmi_type if element.respond_to?(:xmi_type) data end |
#to_table_row ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/lutaml/uml_repository/presenters/association_presenter.rb', line 35 def to_table_row { type: "Association", name: element.name || "(unnamed)", details: "#{source_display} → #{target_display}", } end |
#to_text ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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.respond_to?(:xmi_id) lines << "XMI ID: #{element.xmi_id}" end if element.respond_to?(:xmi_type) lines << "Type: #{element.xmi_type}" end lines << "" lines << "Source: #{source_display}" lines << "Target: #{target_display}" lines.join("\n") end |