Class: Xcodeproj::Workspace::GroupReference

Inherits:
Reference
  • Object
show all
Defined in:
lib/xcodeproj/workspace/group_reference.rb

Overview

Describes a group reference of a Workspace.

Instance Attribute Summary collapse

Attributes inherited from Reference

#type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Reference

prepend_parent_path

Constructor Details

#initialize(name, type = 'container', location = '') ⇒ GroupReference



20
21
22
23
24
# File 'lib/xcodeproj/workspace/group_reference.rb', line 20

def initialize(name, type = 'container', location = '')
  @name = name.to_s
  @type = type.to_s
  @location = location.to_s
end

Instance Attribute Details

#locationString (readonly)



14
15
16
# File 'lib/xcodeproj/workspace/group_reference.rb', line 14

def location
  @location
end

#nameString (readonly)



10
11
12
# File 'lib/xcodeproj/workspace/group_reference.rb', line 10

def name
  @name
end

Class Method Details

.from_node(xml_node) ⇒ GroupReference

Returns a group reference given XML representation.



46
47
48
49
50
51
52
53
54
55
# File 'lib/xcodeproj/workspace/group_reference.rb', line 46

def self.from_node(xml_node)
  location_array = xml_node.attribute('location').value.split(':', 2)
  type = location_array.first
  location = location_array[1] || ''
  if type == 'group'
    location = prepend_parent_path(xml_node, location)
  end
  name = xml_node.attribute('name').value
  new(name, type, location)
end

Instance Method Details

#==(other) ⇒ Bool Also known as: eql?



28
29
30
# File 'lib/xcodeproj/workspace/group_reference.rb', line 28

def ==(other)
  name == other.name && type == other.type && location == other.location
end

#hashFixnum



35
36
37
# File 'lib/xcodeproj/workspace/group_reference.rb', line 35

def hash
  [name, type, location].hash
end

#to_nodeREXML::Element



59
60
61
62
63
64
# File 'lib/xcodeproj/workspace/group_reference.rb', line 59

def to_node
  REXML::Element.new('Group').tap do |element|
    element.add_attribute('location', "#{type}:#{location}")
    element.add_attribute('name', "#{name}")
  end
end