Class: Package

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

Returns a new instance of Package.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/xmimodel/package.rb', line 16

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

  @parent_package = parent_tag.parent_tag unless parent_tag.nil? or parent_tag.class == XmiModel

  @name = xml.attribute("name").to_s
  @full_name = XmiHelper.full_package_name(xml)

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

  self   
end

Instance Attribute Details

#full_nameObject (readonly)

Returns the value of attribute full_name.



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

def full_name
  @full_name
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/xmimodel/package.rb', line 10

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



14
15
16
# File 'lib/xmimodel/package.rb', line 14

def namespace
  @namespace
end

#parent_packageObject (readonly)

Returns the value of attribute parent_package.



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

def parent_package
  @parent_package
end

Instance Method Details

#<=>(obj) ⇒ Object



71
72
73
# File 'lib/xmimodel/package.rb', line 71

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

#==(obj) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/xmimodel/package.rb', line 75

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

#activity_graphsObject



37
38
39
40
# File 'lib/xmimodel/package.rb', line 37

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

#add_xml_class(xml) ⇒ Object



32
33
34
35
# File 'lib/xmimodel/package.rb', line 32

def add_xml_class(xml)
  add_namespace() if !XmiHelper.has_namespace?(self.xml)
  @namespace.xml.inner_html = @namespace.xml.inner_html + xml
end

#class_by_name(name) ⇒ Object



47
48
49
50
51
52
# File 'lib/xmimodel/package.rb', line 47

def class_by_name(name)
  return nil if @namespace.nil?
  clazz = @namespace.classes.select{|c| c.name == name}
  return clazz[0] if !clazz.nil? && clazz.size > 0
  nil
end

#classesObject



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

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

#packagesObject



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

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

#to_sObject



84
85
86
# File 'lib/xmimodel/package.rb', line 84

def to_s
  "Package[#{@full_name}]"
end

#use_case_by_name(name) ⇒ Object



64
65
66
67
68
69
# File 'lib/xmimodel/package.rb', line 64

def use_case_by_name(name)
  return nil if @namespace.nil?
  use_case = @namespace.use_cases.select{|u| u.name == name}
  return use_case[0] if !use_case.nil? && use_case.size > 0
  nil
end

#use_casesObject



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

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