Class: XcodeProject::FileNode
- Defined in:
- lib/xcodeproject/file_node.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#source_tree ⇒ Object
readonly
Returns the value of attribute source_tree.
Attributes inherited from Node
Instance Method Summary collapse
- #group_path ⇒ Object
-
#initialize(root, uuid, data) ⇒ FileNode
constructor
A new instance of FileNode.
- #parent ⇒ Object
- #total_path ⇒ Object
Constructor Details
#initialize(root, uuid, data) ⇒ FileNode
Returns a new instance of FileNode.
10 11 12 13 14 15 16 17 18 |
# File 'lib/xcodeproject/file_node.rb', line 10 def initialize (root, uuid, data) super(root, uuid, data) @source_tree = data['sourceTree'] @name ||= data['name'] @path ||= data['path'] @name ||= File.basename(@path) unless @path.nil? end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/xcodeproject/file_node.rb', line 6 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/xcodeproject/file_node.rb', line 7 def path @path end |
#source_tree ⇒ Object (readonly)
Returns the value of attribute source_tree.
8 9 10 |
# File 'lib/xcodeproject/file_node.rb', line 8 def source_tree @source_tree end |
Instance Method Details
#group_path ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/xcodeproject/file_node.rb', line 30 def group_path obj = self res = '' begin pn = obj.name ? obj.name : '' res = Pathname.new(pn).join(res) end while obj = obj.parent; res.cleanpath end |
#parent ⇒ Object
24 25 26 27 28 |
# File 'lib/xcodeproject/file_node.rb', line 24 def parent root.select_objects do |uuid, data| (data['children'].include?(self.uuid) if data['isa'] == 'PBXGroup') ? true : false end.first end |
#total_path ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/xcodeproject/file_node.rb', line 40 def total_path res = '' case source_tree when :source_root res = path when :group pn = path.nil? ? '' : path res = parent.total_path.join(pn) unless parent.nil? else raise ParseError.new("No such '#{source_tree}' source tree type.") end root.absolute_path(res) end |