Sha256: 4a33ce4be45d8876274ec2fb52bca3eeb60241fc2e06f0474c44fae277931a0e

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

require "lutaml/uml/has_members"
require "lutaml/uml/classifier"
require "lutaml/uml/association"
require "lutaml/uml/top_element_attribute"

module Lutaml
  module Uml
    class Class < Classifier
      include HasMembers

      attr_accessor :nested_classifier,
                    :is_abstract,
                    :type

      attr_reader :associations,
                  :attributes,
                  :definition,
                  :members,
                  :modifier

      def initialize(attributes = {})
        @nested_classifier = []
        @stereotype = []
        @generalization = []
        @is_abstract = false
        super
      end

      def modifier=(value)
        @modifier = value.to_s # TODO: Validate?
      end

      def definition=(value)
        @definition = value.to_s
      end

      def attributes=(value)
        @attributes = value.to_a.map do |attr|
          TopElementAttribute.new(attr)
        end
      end

      def associations=(value)
        @associations = value.to_a.map do |attr|
          Association.new(attr.to_h.merge(owner_end: name))
        end
      end

      def methods
        # @members&.select { |member| member.class == Method }
        []
      end

      def relationships
        # @members&.select { |member| member.class == ClassRelationship }
        []
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lutaml-uml-0.2.7 lib/lutaml/uml/class.rb
lutaml-uml-0.2.6 lib/lutaml/uml/class.rb
lutaml-uml-0.2.5 lib/lutaml/uml/class.rb
lutaml-uml-0.2.4 lib/lutaml/uml/class.rb