Class: UseCase

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

UML:CallEvent


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
47
48
49
# File 'lib/xmimodel/use_case.rb', line 20

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

	@package = parent_tag.parent_tag

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

	if XmiHelper.has_namespace?(xml)
		namespace = XmiHelper.namespace(xml)		
		@namespace = Namespace.new(namespace, self) unless namespace.nil?
	end			

	stereotype_id = xml.attribute("stereotype").to_s
	if !stereotype_id.empty?
		uml_stereotype = XmiHelper.stereotype_by_id(stereotype_id)
		stereotype = Stereotype.new(uml_stereotype, self)
		@stereotypes << stereotype			
	end
	@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

#nameObject (readonly)

Returns the value of attribute name


13
14
15
# File 'lib/xmimodel/use_case.rb', line 13

def name
  @name
end

#packageObject (readonly)

Returns the value of attribute package


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

def package
  @package
end

#stereotypesObject (readonly)

Returns the value of attribute stereotypes


15
16
17
# File 'lib/xmimodel/use_case.rb', line 15

def stereotypes
  @stereotypes
end

#tagged_valuesObject (readonly)

Returns the value of attribute tagged_values


16
17
18
# File 'lib/xmimodel/use_case.rb', line 16

def tagged_values
  @tagged_values
end

Instance Method Details

#<=>(obj) ⇒ Object


90
91
92
# File 'lib/xmimodel/use_case.rb', line 90

def <=>(obj)
   	full_name <=> obj.full_name
end

#==(obj) ⇒ Object


94
95
96
97
98
99
100
101
# File 'lib/xmimodel/use_case.rb', line 94

def ==(obj)
	return false if obj.nil?
	if String == obj.class
		full_name == obj
	else
   		full_name == obj.full_name
   	end
end

#activity_graphsObject


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

def activity_graphs
	return Array.new if @namespace.nil?
	@namespace.activity_graphs
end

#activity_graphs_by_name(name) ⇒ Object


56
57
58
59
60
# File 'lib/xmimodel/use_case.rb', line 56

def activity_graphs_by_name(name)
	activity_graph = activity_graphs.select{|obj| obj.name == name}
	return activity_graph[0] if !activity_graph.nil? && activity_graph.size > 0
	nil			
end

#call_eventsObject


85
86
87
88
# File 'lib/xmimodel/use_case.rb', line 85

def call_events
	return Array.new if @namespace.nil?
	@namespace.call_events
end

#full_nameObject


103
104
105
# File 'lib/xmimodel/use_case.rb', line 103

def full_name
	"#{package.full_name}.#{name}"
end

#signal_event_by_name(name) ⇒ Object


62
63
64
65
66
# File 'lib/xmimodel/use_case.rb', line 62

def signal_event_by_name(name)
	signal_event = signal_events.select{|obj| obj.name == name}
	return signal_event[0] if !signal_event.nil? && signal_event.size > 0
	nil			
end

#signal_eventsObject


68
69
70
71
# File 'lib/xmimodel/use_case.rb', line 68

def signal_events
	return Array.new if @namespace.nil?
	@namespace.signal_events
end

#stereotype_by_name(name) ⇒ Object


73
74
75
76
77
# File 'lib/xmimodel/use_case.rb', line 73

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


79
80
81
82
83
# File 'lib/xmimodel/use_case.rb', line 79

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_sObject


107
108
109
# File 'lib/xmimodel/use_case.rb', line 107

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