Class: Parameter

Inherits:
Object
  • Object
show all
Defined in:
lib/xmimodel/parameter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml, owner) ⇒ 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
# File 'lib/xmimodel/parameter.rb', line 14

def initialize(xml, owner)
	@xml = xml
	@owner = owner

	@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	
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#kindObject (readonly)

Returns the value of attribute kind.



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

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#ownerObject (readonly)

Returns the value of attribute owner.



5
6
7
# File 'lib/xmimodel/parameter.rb', line 5

def owner
  @owner
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

#xmlObject (readonly)

Returns the value of attribute xml.



4
5
6
# File 'lib/xmimodel/parameter.rb', line 4

def xml
  @xml
end

Instance Method Details

#full_nameObject



47
48
49
50
# File 'lib/xmimodel/parameter.rb', line 47

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

#stereotype_by_name(name) ⇒ Object



41
42
43
44
45
# File 'lib/xmimodel/parameter.rb', line 41

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



35
36
37
38
39
# File 'lib/xmimodel/parameter.rb', line 35

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



52
53
54
# File 'lib/xmimodel/parameter.rb', line 52

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