Class: Attribute
Instance Attribute Summary collapse
-
#clazz ⇒ Object
readonly
Returns the value of attribute clazz.
-
#initial_value ⇒ Object
readonly
Returns the value of attribute initial_value.
-
#multiplicity_range ⇒ Object
readonly
Returns the value of attribute multiplicity_range.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#stereotypes ⇒ Object
readonly
Returns the value of attribute stereotypes.
-
#tagged_values ⇒ Object
readonly
Returns the value of attribute tagged_values.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#visibility ⇒ Object
readonly
Returns the value of attribute visibility.
Attributes inherited from Tag
Instance Method Summary collapse
- #==(obj) ⇒ Object
- #add_xml_tagged_value(xml) ⇒ Object
- #enum_obj ⇒ Object
- #full_name ⇒ Object
-
#initialize(xml, parent_tag) ⇒ Attribute
constructor
A new instance of Attribute.
-
#is_enum? ⇒ Boolean
def add_tagged_value(name, value) if tagged_values.include? name tag = tagged_value_by_name name else tagged_value = Nokogiri::XML::Node.new(‘TaggedValue’, self.xml.document) tagged_value = tagged_value = name model_element_tagged_value() << tagged_value end tag.value = value end.
- #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) ⇒ Attribute
20 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 |
# File 'lib/xmimodel/attribute.rb', line 20 def initialize(xml, parent_tag) super(xml, parent_tag) @clazz = parent_tag @name = xml.attribute("name").to_s.strip @visibility = xml.attribute("visibility").to_s @visibility = "private" if @visibility == "" @obj_type = XmiHelper.attribute_type(xml) @type = XmiHelper.attribute_type_name(xml) @initial_value = XmiHelper.attribute_initial_value(xml) @multiplicity_range = XmiHelper.multiplicity_range(xml) @stereotypes = Array.new 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 end |
Instance Attribute Details
#clazz ⇒ Object (readonly)
Returns the value of attribute clazz.
15 16 17 |
# File 'lib/xmimodel/attribute.rb', line 15 def clazz @clazz end |
#initial_value ⇒ Object (readonly)
Returns the value of attribute initial_value.
12 13 14 |
# File 'lib/xmimodel/attribute.rb', line 12 def initial_value @initial_value end |
#multiplicity_range ⇒ Object (readonly)
Returns the value of attribute multiplicity_range.
13 14 15 |
# File 'lib/xmimodel/attribute.rb', line 13 def multiplicity_range @multiplicity_range end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/xmimodel/attribute.rb', line 9 def name @name end |
#stereotypes ⇒ Object (readonly)
Returns the value of attribute stereotypes.
17 18 19 |
# File 'lib/xmimodel/attribute.rb', line 17 def stereotypes @stereotypes end |
#tagged_values ⇒ Object (readonly)
Returns the value of attribute tagged_values.
18 19 20 |
# File 'lib/xmimodel/attribute.rb', line 18 def tagged_values @tagged_values end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/xmimodel/attribute.rb', line 10 def type @type end |
#visibility ⇒ Object (readonly)
Returns the value of attribute visibility.
11 12 13 |
# File 'lib/xmimodel/attribute.rb', line 11 def visibility @visibility end |
Instance Method Details
#==(obj) ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'lib/xmimodel/attribute.rb', line 102 def ==(obj) return false if obj.nil? if String == obj.class full_name == obj else full_name == obj.full_name end end |
#add_xml_tagged_value(xml) ⇒ Object
48 49 50 |
# File 'lib/xmimodel/attribute.rb', line 48 def add_xml_tagged_value(xml) model_element_tagged_value().inner_html = model_element_tagged_value().inner_html + xml end |
#enum_obj ⇒ Object
80 81 82 83 84 |
# File 'lib/xmimodel/attribute.rb', line 80 def enum_obj return @enum_obj unless @enum_obj.nil? is_enum? @enum_obj end |
#full_name ⇒ Object
86 87 88 |
# File 'lib/xmimodel/attribute.rb', line 86 def full_name "#{@clazz.full_name}::#{@name}" end |
#is_enum? ⇒ Boolean
def add_tagged_value(name, value) if tagged_values.include? name tag = tagged_value_by_name name else tagged_value = Nokogiri::XML::Node.new(‘TaggedValue’, self.xml.document) tagged_value = tagged_value = name model_element_tagged_value() << tagged_value end tag.value = value end
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/xmimodel/attribute.rb', line 66 def is_enum? return false if @obj_type.nil? if @obj_type.class == Nokogiri::XML::Element return true if @obj_type.name == "Enumeration" if @obj_type.name == "Class" id = @obj_type.attribute('xmi.id').to_s @enum_obj = xml_root.class_by_id(id) return @enum_obj.stereotypes.include?("org.andromda.profile::Enumeration") end end false end |
#stereotype_by_name(name) ⇒ Object
90 91 92 93 94 |
# File 'lib/xmimodel/attribute.rb', line 90 def stereotype_by_name(name) stereotype = @stereotypes.select{|s| s.name == name} return stereotype[0] if !stereotype.nil? && stereotype.size > 0 nil end |
#tagged_value_by_name(tagged_value_name) ⇒ Object
96 97 98 99 100 |
# File 'lib/xmimodel/attribute.rb', line 96 def tagged_value_by_name(tagged_value_name) tagged_value = @tagged_values.select{|t| t.name == tagged_value_name} return tagged_value[0] if !tagged_value.nil? && tagged_value.size > 0 nil end |
#to_s ⇒ Object
111 112 113 |
# File 'lib/xmimodel/attribute.rb', line 111 def to_s "Attribute[#{full_name}]" end |