Class: Xcake::Node
Overview
This class is used to represent a node (File or Directory) in the File System.
This tracks which target the node should be added to.
Instance Attribute Summary collapse
-
#children ⇒ Array<Node>
The child nodes.
-
#component ⇒ String
The component of this node in the path.
-
#parent ⇒ String
The parent node.
-
#path ⇒ String
The path to this node relative to the Cakefile.
-
#targets ⇒ Array<PBXNativeTarget>
The targets for the node.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
-
#create_children_with_path(path, target) ⇒ Object
Creates child nodes for the path and target.
-
#initialize ⇒ Node
constructor
A new instance of Node.
-
#remove_children_with_path(path, target) ⇒ Object
Removes child nodes for the path and target.
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
32 33 34 35 |
# File 'lib/xcake/node.rb', line 32 def initialize self.children = [] self.targets = [] end |
Instance Attribute Details
#children ⇒ Array<Node>
Returns the child nodes.
26 27 28 |
# File 'lib/xcake/node.rb', line 26 def children @children end |
#component ⇒ String
Returns the component of this node in the path.
14 15 16 |
# File 'lib/xcake/node.rb', line 14 def component @component end |
#parent ⇒ String
Returns the parent node.
22 23 24 |
# File 'lib/xcake/node.rb', line 22 def parent @parent end |
#path ⇒ String
Returns the path to this node relative to the Cakefile.
18 19 20 |
# File 'lib/xcake/node.rb', line 18 def path @path end |
#targets ⇒ Array<PBXNativeTarget>
Returns the targets for the node.
30 31 32 |
# File 'lib/xcake/node.rb', line 30 def targets @targets end |
Instance Method Details
#accept(visitor) ⇒ Object
128 129 130 131 132 133 134 135 136 |
# File 'lib/xcake/node.rb', line 128 def accept(visitor) visitor.visit(self) children.each do |c| c.accept(visitor) end visitor.leave(self) end |
#create_children_with_path(path, target) ⇒ Object
Creates child nodes for the path and target.
46 47 48 49 50 51 52 |
# File 'lib/xcake/node.rb', line 46 def create_children_with_path(path, target) components = path.split('/').keep_if do |c| c != '.' end create_children_with_components(components, target) end |
#remove_children_with_path(path, target) ⇒ Object
Removes child nodes for the path and target.
63 64 65 66 67 68 69 |
# File 'lib/xcake/node.rb', line 63 def remove_children_with_path(path, target) components = path.split('/').keep_if do |c| c != '.' end remove_children_with_components(components, target) end |