class XcodeProject::PBXFileReference

Constants

FileTypeMap

Public Class Methods

add(root, path) click to toggle source
# 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
new(root, uuid, data) click to toggle source
Calls superclass method XcodeProject::FileNode::new
# File lib/xcodeproject/pbx_file_reference.rb, line 30
def initialize(root, uuid, data)
  super(root, uuid, data)
end

Private Class Methods

create_object_hash(path) click to toggle source
# 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

Public Instance Methods

remove!() click to toggle source
# File lib/xcodeproject/pbx_file_reference.rb, line 34
def remove!
  root.build_files(uuid).each(&:remove!)

  parent.remove_child_uuid(uuid)
  root.remove_object(uuid)
end