Class: Xcake::Node

Inherits:
Object show all
Includes:
Visitable
Defined in:
lib/xcake/node.rb

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

Instance Method Summary collapse

Constructor Details

#initializeNode

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

#childrenArray<Node>

Returns the child nodes.

Returns:



26
27
28
# File 'lib/xcake/node.rb', line 26

def children
  @children
end

#componentString

Returns the component of this node in the path.

Returns:

  • (String)

    the component of this node in the path.



14
15
16
# File 'lib/xcake/node.rb', line 14

def component
  @component
end

#parentString

Returns the parent node.

Returns:

  • (String)

    the parent node.



22
23
24
# File 'lib/xcake/node.rb', line 22

def parent
  @parent
end

#pathString

Returns the path to this node relative to the Cakefile.

Returns:

  • (String)

    the path to this node relative to the Cakefile.



18
19
20
# File 'lib/xcake/node.rb', line 18

def path
  @path
end

#targetsArray<PBXNativeTarget>

Returns the targets for the node.

Returns:

  • (Array<PBXNativeTarget>)

    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.

Parameters:

  • path (String)

    path to create children for

  • target (PBXNativeTarget)

    target to add for the child nodes



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.

Parameters:

  • path (String)

    path to remove children for

  • target (PBXNativeTarget)

    target to remove for child nodes



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