Class: Parameter

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

Returns a new instance of Parameter.


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/xmimodel/parameter.rb', line 14

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

	@id = xml.attribute("xmi:id").to_s
	@name = xml.attribute("name").to_s
	@kind = xml.attribute("kind").to_s

	@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	

	#type = xml.attribute('type').to_s
	@obj_type = XmiHelper.attribute_type(xml)
	@type = XmiHelper.attribute_type_name(xml)	#@type = @obj_type

end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind


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

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name


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

def name
  @name
end

#stereotypesObject (readonly)

Returns the value of attribute stereotypes


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

def stereotypes
  @stereotypes
end

#tagged_valuesObject (readonly)

Returns the value of attribute tagged_values


12
13
14
# File 'lib/xmimodel/parameter.rb', line 12

def tagged_values
  @tagged_values
end

#typeObject (readonly)

Returns the value of attribute type


9
10
11
# File 'lib/xmimodel/parameter.rb', line 9

def type
  @type
end

Instance Method Details

#full_nameObject


65
66
67
68
# File 'lib/xmimodel/parameter.rb', line 65

def full_name
	return "#{@parent_tag.full_name}::#{@kind}" if (@name.nil? || @name.empty?)
	return "#{@parent_tag.full_name}::#{@name}" 		
end

#is_enum?Boolean

Returns:

  • (Boolean)

39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/xmimodel/parameter.rb', line 39

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


59
60
61
62
63
# File 'lib/xmimodel/parameter.rb', line 59

def stereotype_by_name(name)
	stereotype = @stereotypes.select{|obj| obj.name == name}
	return stereotype[0] if !stereotype.nil? && stereotype.size > 0
	nil		
end

#tagged_value_by_name(tagged_value_name) ⇒ Object


53
54
55
56
57
# File 'lib/xmimodel/parameter.rb', line 53

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_sObject


70
71
72
# File 'lib/xmimodel/parameter.rb', line 70

def to_s
	"Parameter[#{full_name}]"
end