Class: TaggedValue

Inherits:
Tag
  • Object
show all
Defined in:
lib/xmimodel/tagged_value.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_tag) ⇒ TaggedValue

Returns a new instance of TaggedValue.


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/xmimodel/tagged_value.rb', line 10

def initialize(xml, parent_tag)
	super(xml, parent_tag)

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

	if @name.nil? or @name.empty?
		tag_definition = XmiHelper.taggeg_value_tag_definition(xml)
		tag_definition_id_ref = tag_definition.attribute("xmi.idref").to_s			
		tag_definition = XmiHelper.tag_definition_by_id(xml, tag_definition_id_ref)
		@name = tag_definition.attribute("name").to_s
	end

	@value = XmiHelper.taggeg_value_data_value(xml)
	@value = XmiHelper.taggeg_value_reference_value(xml) if (@value.nil? || @value.empty?)

end

Instance Attribute Details

#nameObject

Returns the value of attribute name


7
8
9
# File 'lib/xmimodel/tagged_value.rb', line 7

def name
  @name
end

#valueObject

Returns the value of attribute value


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

def value
  @value
end

Instance Method Details

#==(obj) ⇒ Object


34
35
36
37
38
39
40
41
# File 'lib/xmimodel/tagged_value.rb', line 34

def ==(obj)
	return false if obj.nil?
	if String == obj.class
		return "#{@name}".eql?(obj)
	else
		return @name.eql?(obj.name)
	end
end

#to_sObject


43
44
45
# File 'lib/xmimodel/tagged_value.rb', line 43

def to_s
	"TaggedValue[#{@name}=#{@value}]"
end