Class: Xcodeproj::Workspace::GroupReference
- Defined in:
- lib/xcodeproj/workspace/group_reference.rb
Overview
Describes a group reference of a Workspace.
Instance Attribute Summary collapse
-
#location ⇒ String
readonly
The location of the group on disk.
-
#name ⇒ String
readonly
The name of the group.
Attributes inherited from Reference
Class Method Summary collapse
-
.from_node(xml_node) ⇒ GroupReference
Returns a group reference given XML representation.
Instance Method Summary collapse
-
#==(other) ⇒ Bool
(also: #eql?)
Whether a group reference is equal to another.
-
#hash ⇒ Fixnum
A hash identical for equals objects.
-
#initialize(name, type = 'container', location = '') ⇒ GroupReference
constructor
A new instance of GroupReference.
-
#to_node ⇒ REXML::Element
The XML representation of the group reference.
Methods inherited from Reference
Constructor Details
#initialize(name, type = 'container', location = '') ⇒ GroupReference
Returns a new instance of 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
#location ⇒ String (readonly)
Returns the location of the group on disk.
14 15 16 |
# File 'lib/xcodeproj/workspace/group_reference.rb', line 14 def location @location end |
#name ⇒ String (readonly)
Returns the name of the group.
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?
Returns Whether a group reference is equal to another.
28 29 30 |
# File 'lib/xcodeproj/workspace/group_reference.rb', line 28 def ==(other) name == other.name && type == other.type && location == other.location end |
#hash ⇒ Fixnum
Returns A hash identical for equals objects.
35 36 37 |
# File 'lib/xcodeproj/workspace/group_reference.rb', line 35 def hash [name, type, location].hash end |
#to_node ⇒ REXML::Element
Returns the XML representation of the group reference.
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 |