Class: XcodeProject::PBXFileReference
- Defined in:
- lib/xcodeproject/pbx_file_reference.rb
Constant Summary collapse
- FileTypeMap =
{ '.h' => 'sourcecode.c.h', '.c' => 'sourcecode.c.c', '.m' => 'sourcecode.c.objc', '.mm' => 'sourcecode.cpp.objcpp', '.hpp' => 'sourcecode.cpp.h', '.cpp' => 'sourcecode.cpp.cpp', '.cc' => 'sourcecode.cpp.cpp', '.swift' => 'sourcecode.swift', '.mp3' => 'audio.mp3', '.png' => 'image.png', '.jpeg' => 'image.jpeg', '.jpg' => 'image.jpeg', '.fnt' => 'text', '.txt' => 'text' }.freeze
Constants inherited from FileNode
Instance Attribute Summary
Attributes inherited from FileNode
Attributes inherited from Node
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(root, uuid, data) ⇒ PBXFileReference
constructor
A new instance of PBXFileReference.
- #remove! ⇒ Object
Methods inherited from FileNode
#group_path, #parent, #total_path
Constructor Details
#initialize(root, uuid, data) ⇒ PBXFileReference
Returns a new instance of PBXFileReference.
30 31 32 |
# File 'lib/xcodeproject/pbx_file_reference.rb', line 30 def initialize(root, uuid, data) super(root, uuid, data) end |
Class Method Details
.add(root, path) ⇒ Object
41 42 43 44 |
# File 'lib/xcodeproject/pbx_file_reference.rb', line 41 def self.add(root, path) uuid, data = root.add_object(create_object_hash(path)) new(root, uuid, data) end |
.create_object_hash(path) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/xcodeproject/pbx_file_reference.rb', line 48 def self.create_object_hash(path) path = path.to_s name = File.basename(path) ext = File.extname(path) raise ParseError, "No such file type '#{name}'." unless FileTypeMap.include?(ext) data = [] data << %w[isa PBXFileReference] data << ['sourceTree', '<group>'] # data << ['fileEncoding', '4'] # utf-8 data << ['lastKnownFileType', FileTypeMap[ext]] data << ['path', path] data << ['name', name] if name != path Hash[data] end |