Class: ZergXcode::Objects::PBXGroup
- Inherits:
-
XcodeObject
- Object
- XcodeObject
- ZergXcode::Objects::PBXGroup
- 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 collapse
-
#children ⇒ Object
readonly
An array of all immediate children of this node.
Attributes inherited from XcodeObject
Instance Method Summary collapse
-
#child_with_name(name) ⇒ Object
If this group has an immediate child with the specified name, it is returned; otherwise, nil is returned.
-
#child_with_path(path) ⇒ Object
(also: #exist?, #exists?)
If a child exists at the specified path (which may contain slashes), that child is returned.
-
#mkdir(name) ⇒ Object
call-seq: mkdir(name) ⇒ aChild.
-
#mkdir_f(name) ⇒ Object
call-seq: mkdir_f(name) ⇒ aChild.
-
#mkdir_p(path) ⇒ Object
call-seq: mkdir_p(path) ⇒ aChild.
-
#to_s ⇒ Object
:nodoc:.
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 Attribute Details
#children ⇒ Object (readonly)
An array of all immediate children of this node
52 53 54 |
# File 'lib/zerg_xcode/objects/pbx_group.rb', line 52 def children @children end |
Instance Method Details
#child_with_name(name) ⇒ Object
If this group has an immediate child with the specified name, it is returned; otherwise, nil is returned.
69 70 71 |
# File 'lib/zerg_xcode/objects/pbx_group.rb', line 69 def child_with_name name children.detect {|child| child.xref_name == name} end |
#child_with_path(path) ⇒ Object Also known as: exist?, exists?
If a child exists at the specified path (which may contain slashes), that child is returned. Otherwise, nil is returned.
59 60 61 62 63 |
# File 'lib/zerg_xcode/objects/pbx_group.rb', line 59 def child_with_path path path_elements(path).inject(self) do |group, path_element| group.child_with_name(path_element) if group end end |
#mkdir(name) ⇒ Object
call-seq:
mkdir(name) ⇒ aChild
Creates a child group with name name. Raises Errno::EEXIST if a child with that name already exists.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/zerg_xcode/objects/pbx_group.rb', line 19 def mkdir name raise Errno::ENOTNAM if name =~ /\// raise Errno::EEXIST if exists? name group = ZergXcode::Objects::PBXGroup.new 'name' => name, 'path' => name, 'children' => [], 'sourceTree' => '<group>' self.children << group group end |
#mkdir_f(name) ⇒ Object
call-seq:
mkdir_f(name) ⇒ aChild
If a child with name name already exists, that child is returned; otherwise, a new child group is created and returned.
35 36 37 |
# File 'lib/zerg_xcode/objects/pbx_group.rb', line 35 def mkdir_f name child_with_name(name) || mkdir(name) end |
#mkdir_p(path) ⇒ Object
call-seq:
mkdir_p(path) ⇒ aChild
If a child with path path exists, that child is returned; otherwise, groups are created to make the path exist and the deepest group is returned.
45 46 47 48 49 |
# File 'lib/zerg_xcode/objects/pbx_group.rb', line 45 def mkdir_p path path_elements(path).inject(self) do |group, path_element| group.mkdir_f path_element end end |
#to_s ⇒ Object
:nodoc:
74 75 76 |
# File 'lib/zerg_xcode/objects/pbx_group.rb', line 74 def to_s "PBXGroup<#{xref_name}>" end |