Class: Association

Inherits:
Tag
  • Object
show all
Defined in:
lib/xmimodel/association.rb

Instance Attribute Summary collapse

Attributes inherited from Tag

#id, #parent_tag, #xml

Instance Method Summary collapse

Methods inherited from Tag

#xml_root

Constructor Details

#initialize(xml, parent) ⇒ Association

Returns a new instance of Association.



13
14
15
16
17
18
19
20
21
22
# File 'lib/xmimodel/association.rb', line 13

def initialize(xml, parent)
  super(xml, parent)

  @name = xml.attribute("name").to_s.strip

  association_end = xml.xpath('./UML:Association.connection/UML:AssociationEnd')

  @end_a = AssociationEnd.new(association_end, 0, self)
  @end_b = AssociationEnd.new(association_end, 1, self)
end

Instance Attribute Details

#end_aObject (readonly)

Returns the value of attribute end_a.



10
11
12
# File 'lib/xmimodel/association.rb', line 10

def end_a
  @end_a
end

#end_bObject (readonly)

Returns the value of attribute end_b.



11
12
13
# File 'lib/xmimodel/association.rb', line 11

def end_b
  @end_b
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/xmimodel/association.rb', line 8

def name
  @name
end

Instance Method Details

#full_nameString

Returns:

  • (String)


25
26
27
28
29
30
31
# File 'lib/xmimodel/association.rb', line 25

def full_name
  if @name.nil? or @name.empty?
    "#{@end_a.name}[#{@end_a.participant.full_name}] - #{@end_b.name}[#{@end_b.participant.full_name}]"
  else
    "#{@name}(#{@end_a.name}[#{@end_a.participant.full_name}] - #{@end_b.name}[#{@end_b.participant.full_name}])"
  end
end

#to_sObject



33
34
35
# File 'lib/xmimodel/association.rb', line 33

def to_s
  "Association[#{@name}]"
end