Class: ZergXcode::Objects::PBXGroup

Inherits:
XcodeObject show all
Defined in:
lib/zerg_xcode/objects/pbx_group.rb

Overview

A group of files (shown as a folder) in an Xcode project.

Instance Attribute Summary

Attributes inherited from XcodeObject

#archive_id, #version

Instance Method Summary collapse

Methods inherited from XcodeObject

#[], #[]=, #_attr_hash, #attrs, #copy_metadata, from, #initialize, #isa, new, #shallow_copy, #visit, #visit_array, #visit_hash, #visit_once, #visit_value, #xref_key, #xref_name

Constructor Details

This class inherits a constructor from ZergXcode::XcodeObject

Instance Method Details

#childrenObject



26
27
28
# File 'lib/zerg_xcode/objects/pbx_group.rb', line 26

def children
  self['children']
end

#create_group(path_name, group_name = nil, source_tree = '<group>') ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/zerg_xcode/objects/pbx_group.rb', line 30

def create_group(path_name, group_name=nil, source_tree='<group>')
  group_name = group_name || path_name
  unless group = find_group_named(group_name)
    group = ZergXcode::Objects::PBXGroup.new 'name' => group_name, 
                                             'path' => path_name, 
                                             'children' => [], 
                                             'sourceTree' => source_tree
    self.children << group
  end
  group
end

#find_group_named(group_name) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/zerg_xcode/objects/pbx_group.rb', line 13

def find_group_named(group_name)
  self['children'].each do |child|
    if child.isa == :PBXGroup
      if child.xref_name == group_name
        return child
      elsif grandchild = child.find_group_named(group_name)
        return grandchild
      end
    end
  end
  return nil
end