Class: Operation

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

Returns a new instance of Operation.


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/xmimodel/operation.rb', line 13

def initialize(xml, parent)
	super(xml, parent)

	@clazz = parent

	@name = xml.attribute("name").to_s
	@visibility = xml.attribute("visibility").to_s
	@visibility = "private" if @visibility == ""
	
	@parameters = Array.new
	XmiHelper.parameters(xml).each do |uml_parameter|
		parameter = Parameter.new(uml_parameter, self)
		@parameters << parameter
	end		
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


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

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters


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

def parameters
  @parameters
end

#visibilityObject (readonly)

Returns the value of attribute visibility


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

def visibility
  @visibility
end

Instance Method Details

#==(obj) ⇒ Object


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

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

#full_nameObject


44
45
46
# File 'lib/xmimodel/operation.rb', line 44

def full_name
	"#{@clazz.full_name}::#{@name}"
end

#parameter_by_name(name) ⇒ Object


29
30
31
32
33
# File 'lib/xmimodel/operation.rb', line 29

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

#to_sObject


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

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