Class: Stereotype
- Inherits:
-
Object
- Object
- Stereotype
- Defined in:
- lib/xmimodel/stereotype.rb
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #<=>(obj) ⇒ Object
-
#initialize(xml, owner) ⇒ Stereotype
constructor
A new instance of Stereotype.
- #name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(xml, owner) ⇒ Stereotype
Returns a new instance of Stereotype.
7 8 9 10 11 12 13 14 15 |
# File 'lib/xmimodel/stereotype.rb', line 7 def initialize(xml, owner) @xml = xml @owner = owner @id = xml.attribute("xmi.id").to_s @name = xml.attribute("name").to_s @href = xml.attribute("href").to_s @idref = xml.attribute("xmi.idref").to_s end |
Instance Attribute Details
#href ⇒ Object (readonly)
Returns the value of attribute href.
5 6 7 |
# File 'lib/xmimodel/stereotype.rb', line 5 def href @href end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
4 5 6 |
# File 'lib/xmimodel/stereotype.rb', line 4 def xml @xml end |
Instance Method Details
#<=>(obj) ⇒ Object
17 18 19 |
# File 'lib/xmimodel/stereotype.rb', line 17 def <=>(obj) href <=> obj.href end |
#name ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/xmimodel/stereotype.rb', line 21 def name return @name unless (@name.nil? or @name.empty?) @name = XmiHelper.extension_referent_path_value(xml) if @name.empty? # Se 'xmi.idref' não for null, o documento irá apontar para o id de outra tag # UML:Stereotype (que estará dentro de UML:Namespace.ownedElement e não UML:ModelElement.stereotype) id = @idref.empty? ? @href : @idref xml = XmiHelper.stereotype_by_id(@xml, id) if !xml.nil? @id = xml.attribute("xmi.id").to_s @name = xml.attribute("name").to_s @isSpecification = xml.attribute("isSpecification").to_s @isRoot = xml.attribute("isRoot").to_s @isLeaf = xml.attribute("isLeaf").to_s @isAbstract = xml.attribute("isAbstract").to_s end end if @name.empty? App.logger.warn "Stereotype not found. Id: #{@id}" @name = @href end @name end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/xmimodel/stereotype.rb', line 49 def to_s "Stereotype[#{name}]" end |