Class: Lutaml::UmlRepository::Presenters::AttributePresenter
- Inherits:
-
ElementPresenter
- Object
- ElementPresenter
- Lutaml::UmlRepository::Presenters::AttributePresenter
- Defined in:
- lib/lutaml/uml_repository/presenters/attribute_presenter.rb
Overview
Presenter for UML Attribute elements.
Formats attribute information including type, cardinality, and owning class.
Instance Attribute Summary
Attributes inherited from ElementPresenter
#context, #element, #repository
Instance Method Summary collapse
-
#initialize(element, repository = nil, context = nil) ⇒ AttributePresenter
constructor
A new instance of AttributePresenter.
-
#to_hash ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
- #to_table_row ⇒ Object
-
#to_text ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength.
Constructor Details
#initialize(element, repository = nil, context = nil) ⇒ AttributePresenter
Returns a new instance of AttributePresenter.
14 15 16 |
# File 'lib/lutaml/uml_repository/presenters/attribute_presenter.rb', line 14 def initialize(element, repository = nil, context = nil) super end |
Instance Method Details
#to_hash ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/lutaml/uml_repository/presenters/attribute_presenter.rb', line 47 def to_hash # rubocop:disable Metrics/AbcSize,Metrics/MethodLength data = { type: "Attribute", name: element.name, class_name: class_name, attr_type: element.type, cardinality: format_cardinality(element), } if element.respond_to?(:visibility) data[:visibility] = element.visibility end if element.respond_to?(:stereotype) data[:stereotype] = element.stereotype end if element.respond_to?(:is_derived) data[:is_derived] = element.is_derived end data end |
#to_table_row ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/lutaml/uml_repository/presenters/attribute_presenter.rb', line 39 def to_table_row { type: "Attribute", name: element.name || "(unnamed)", details: "#{class_name}::#{element.name} : #{element.type}", } end |
#to_text ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lutaml/uml_repository/presenters/attribute_presenter.rb', line 18 def to_text # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength lines = [] lines << "Attribute: #{qualified_name}" lines << ("=" * 50) lines << "" lines << "Name: #{element.name}" lines << "Class: #{class_name}" lines << "Type: #{element.type || 'Unknown'}" lines << "Cardinality: #{format_cardinality(element)}" if element.respond_to?(:visibility) && element.visibility lines << "Visibility: #{element.visibility}" end if element.respond_to?(:stereotype) && element.stereotype lines << "Stereotype: #{element.stereotype}" end if element.respond_to?(:is_derived) lines << "Is Derived: #{element.is_derived}" end lines.join("\n") end |