Class: Lutaml::Qea::Factory::StereotypeLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/qea/factory/stereotype_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(database) ⇒ StereotypeLoader

Returns a new instance of StereotypeLoader.



7
8
9
# File 'lib/lutaml/qea/factory/stereotype_loader.rb', line 7

def initialize(database)
  @database = database
end

Instance Method Details

#load_from_xref(ea_guid) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/lutaml/qea/factory/stereotype_loader.rb', line 11

def load_from_xref(ea_guid)
  return nil if ea_guid.nil?
  return nil unless @database.xrefs

  xref = @database.xrefs.find do |x|
    x.client == ea_guid && x.name == "Stereotypes" &&
      x.type == "element property"
  end

  return nil unless xref

  description = xref.description
  return nil if description.nil? || description.empty?

  if description =~ /@STEREO;Name=([^;]+);/
    return Regexp.last_match(1)
  end

  nil
end