Sha256: 0b5226f8d4cf435b9240968572c37d730b2fc9e972a43ce022ffa6e74c1ff187

Contents?: true

Size: 1.85 KB

Versions: 31

Compression:

Stored size: 1.85 KB

Contents

# frozen_string_literal: true

require "lutaml/uml/classifier"

require "lutaml/uml/has_members"
require "lutaml/uml/association"
require "lutaml/uml/constraint"
require "lutaml/uml/data_type"
require "lutaml/uml/operation"
require "lutaml/uml/top_element_attribute"

module Lutaml
  module Uml
    class Class < Classifier
      include HasMembers

      attr_accessor :nested_classifier,
                    :is_abstract,
                    :type,
                    :package

      attr_reader :associations,
                  :attributes,
                  :members,
                  :modifier,
                  :constraints,
                  :operations,
                  :data_types

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

      def modifier=(value)
        @modifier = value.to_s # TODO: Validate?
      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 constraints=(value)
        @constraints = value.to_a.map do |attr|
          Constraint.new(attr)
        end
      end

      def operations=(value)
        @operations = value.to_a.map do |attr|
          Operation.new(attr)
        end
      end

      def data_types=(value)
        @data_types = value.to_a.map do |attr|
          DataType.new(attr)
        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

31 entries across 31 versions & 2 rubygems

Version Path
lutaml-0.9.5 lib/lutaml/uml/class.rb
lutaml-0.9.4 lib/lutaml/uml/class.rb
lutaml-0.9.3 lib/lutaml/uml/class.rb
lutaml-0.9.2 lib/lutaml/uml/class.rb
lutaml-0.9.1 lib/lutaml/uml/class.rb
lutaml-0.9.0 lib/lutaml/uml/class.rb
lutaml-0.8.1 lib/lutaml/uml/class.rb
lutaml-0.8.0 lib/lutaml/uml/class.rb
lutaml-uml-0.4.3 lib/lutaml/uml/class.rb
lutaml-uml-0.4.1 lib/lutaml/uml/class.rb
lutaml-uml-0.4.0 lib/lutaml/uml/class.rb