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.
34 35 36 37 38 39 40 41 42 |
# File 'lib/xcodeproject/file_node.rb', line 34 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.
30 31 32 |
# File 'lib/xcodeproject/file_node.rb', line 30 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
31 32 33 |
# File 'lib/xcodeproject/file_node.rb', line 31 def path @path end |
#source_tree ⇒ Object (readonly)
Returns the value of attribute source_tree.
32 33 34 |
# File 'lib/xcodeproject/file_node.rb', line 32 def source_tree @source_tree end |
Instance Method Details
#group_path ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/xcodeproject/file_node.rb', line 54 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
48 49 50 51 52 |
# File 'lib/xcodeproject/file_node.rb', line 48 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
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/xcodeproject/file_node.rb', line 64 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 |