Class: Clazz
Instance Attribute Summary collapse
-
#associations ⇒ Array<AssociationEnd>
readonly
Class associations end.
-
#attributes ⇒ Array<Attribute>
readonly
Class attributes.
-
#children ⇒ Object
Returns the value of attribute children.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
-
#package ⇒ String
readonly
Full Package name of class.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#stereotypes ⇒ Array<Stereotype>
readonly
Class stereotypes.
-
#tagged_values ⇒ Array<TaggedValue>
readonly
Class tagged values.
Attributes inherited from Tag
Instance Method Summary collapse
- #<=>(obj) ⇒ Object
- #==(obj) ⇒ Object
- #add_xml_attribute(xml_attribute) ⇒ Object
- #add_xml_stereotype(xml) ⇒ Object
- #association_end_by_name_and_participant(associations_end_name, participant) ⇒ AssociationEnd
- #associations_end_by_participant(participant) ⇒ Array<AssociationEnd>
- #attribute_by_id(attribute_id) ⇒ Object
- #attribute_by_name(attribute_name) ⇒ Object
- #full_name ⇒ Object
-
#initialize(xml, parent_tag) ⇒ Clazz
constructor
A new instance of Clazz.
- #operation_by_name(operation_name) ⇒ Object
- #stereotype_by_name(name) ⇒ Object
- #tagged_value_by_name(tagged_value_name) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Tag
Constructor Details
#initialize(xml, parent_tag) ⇒ Clazz
Returns a new instance of Clazz.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/xmimodel/clazz.rb', line 33 def initialize(xml, parent_tag) super(xml, parent_tag) @package = parent_tag.parent_tag @name = xml.attribute("name").to_s.strip @attributes = Array.new XmiHelper.attributes(xml).each do |uml_attribute| attribute = Attribute.new(uml_attribute, self) @attributes << attribute end @stereotypes = Array.new stereotype_id = xml.attribute("stereotype").to_s if !stereotype_id.empty? stereotype = XmiHelper.stereotype_by_id(xml, stereotype_id) stereotype = Stereotype.new(stereotype, self) @stereotypes << stereotype end XmiHelper.stereotypes(xml).each do |uml_stereotype| stereotype = Stereotype.new(uml_stereotype, self) @stereotypes << stereotype end @tagged_values = Array.new XmiHelper.tagged_values(xml).each do |uml_tagged_value| tagged_value = TaggedValue.new(uml_tagged_value, self) @tagged_values << tagged_value end @operations = Array.new XmiHelper.operations(xml).each do |uml_operation| tagged_value = Operation.new(uml_operation, self) @operations << tagged_value end # Será povoado quando tratar dos objetos do tipo Genezalization @children = Array.new @associations = Array.new end |
Instance Attribute Details
#associations ⇒ Array<AssociationEnd> (readonly)
Returns Class associations end.
31 32 33 |
# File 'lib/xmimodel/clazz.rb', line 31 def associations @associations end |
#attributes ⇒ Array<Attribute> (readonly)
Returns Class attributes.
17 18 19 |
# File 'lib/xmimodel/clazz.rb', line 17 def attributes @attributes end |
#children ⇒ Object
Returns the value of attribute children.
27 28 29 |
# File 'lib/xmimodel/clazz.rb', line 27 def children @children end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/xmimodel/clazz.rb', line 11 def name @name end |
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
25 26 27 |
# File 'lib/xmimodel/clazz.rb', line 25 def operations @operations end |
#package ⇒ String (readonly)
Returns Full Package name of class.
14 15 16 |
# File 'lib/xmimodel/clazz.rb', line 14 def package @package end |
#parent ⇒ Object
Returns the value of attribute parent.
28 29 30 |
# File 'lib/xmimodel/clazz.rb', line 28 def parent @parent end |
#stereotypes ⇒ Array<Stereotype> (readonly)
Returns Class stereotypes.
20 21 22 |
# File 'lib/xmimodel/clazz.rb', line 20 def stereotypes @stereotypes end |
#tagged_values ⇒ Array<TaggedValue> (readonly)
Returns Class tagged values.
23 24 25 |
# File 'lib/xmimodel/clazz.rb', line 23 def tagged_values @tagged_values end |
Instance Method Details
#<=>(obj) ⇒ Object
150 151 152 |
# File 'lib/xmimodel/clazz.rb', line 150 def <=>(obj) full_name <=> obj.full_name end |
#==(obj) ⇒ Object
154 155 156 157 158 159 160 161 |
# File 'lib/xmimodel/clazz.rb', line 154 def ==(obj) return false if obj.nil? if String == obj.class full_name == obj else full_name == obj.full_name end end |
#add_xml_attribute(xml_attribute) ⇒ Object
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/xmimodel/clazz.rb', line 77 def add_xml_attribute(xml_attribute) parent = self.xml.at_xpath('./UML:Classifier.feature') if parent.nil? parent = Nokogiri::XML::Node.new('Classifier.feature', self.xml.document) self.xml << parent end parent.inner_html = parent.inner_html + xml_attribute @attributes << Attribute.new(uml_attribute, self) end |
#add_xml_stereotype(xml) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/xmimodel/clazz.rb', line 90 def add_xml_stereotype(xml) parent = self.xml.at_xpath('./UML:ModelElement.stereotype') if parent.nil? parent = Nokogiri::XML::Node.new('ModelElement.stereotype', self.xml.document) self.xml << parent end parent.inner_html = parent.inner_html + xml.to_xml stereotype = Stereotype.new(xml, self) @stereotypes << stereotype return stereotype end |
#association_end_by_name_and_participant(associations_end_name, participant) ⇒ AssociationEnd
107 108 109 110 111 |
# File 'lib/xmimodel/clazz.rb', line 107 def association_end_by_name_and_participant(associations_end_name, participant) obj = @associations.select{|obj| obj.name == associations_end_name && obj.participant == participant} return obj[0] if !obj.nil? && obj.size > 0 nil end |
#associations_end_by_participant(participant) ⇒ Array<AssociationEnd>
116 117 118 |
# File 'lib/xmimodel/clazz.rb', line 116 def associations_end_by_participant(participant) obj = @associations.select{|obj| obj.participant == participant} end |
#attribute_by_id(attribute_id) ⇒ Object
120 121 122 123 124 |
# File 'lib/xmimodel/clazz.rb', line 120 def attribute_by_id(attribute_id) attribute = @attributes.select{|obj| obj.id == attribute_id} return attribute[0] if !attribute.nil? && attribute.size > 0 nil end |
#attribute_by_name(attribute_name) ⇒ Object
126 127 128 129 130 |
# File 'lib/xmimodel/clazz.rb', line 126 def attribute_by_name(attribute_name) attribute = @attributes.select{|obj| obj.name == attribute_name} return attribute[0] if !attribute.nil? && attribute.size > 0 nil end |
#full_name ⇒ Object
163 164 165 |
# File 'lib/xmimodel/clazz.rb', line 163 def full_name "#{package.full_name}.#{name}" end |
#operation_by_name(operation_name) ⇒ Object
132 133 134 135 136 |
# File 'lib/xmimodel/clazz.rb', line 132 def operation_by_name(operation_name) operation = @operations.select{|obj| obj.name == operation_name} return operation[0] if !operation.nil? && operation.size > 0 nil end |
#stereotype_by_name(name) ⇒ Object
138 139 140 141 142 |
# File 'lib/xmimodel/clazz.rb', line 138 def stereotype_by_name(name) stereotype = @stereotypes.select{|obj| obj == name} return stereotype[0] if !stereotype.nil? && stereotype.size > 0 nil end |
#tagged_value_by_name(tagged_value_name) ⇒ Object
144 145 146 147 148 |
# File 'lib/xmimodel/clazz.rb', line 144 def tagged_value_by_name(tagged_value_name) tagged_value = @tagged_values.select{|obj| obj.name == tagged_value_name} return tagged_value[0] if !tagged_value.nil? && tagged_value.size > 0 nil end |
#to_s ⇒ Object
167 168 169 |
# File 'lib/xmimodel/clazz.rb', line 167 def to_s "Clazz[#{full_name}]" end |