Class: Xcode::PBXFileReference

Inherits:
Object
  • Object
show all
Includes:
PBXFormatter
Defined in:
lib/xcode/pbx_file_reference.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PBXFormatter

#to_pbx

Constructor Details

#initialize(attributes, file_type = nil) ⇒ PBXFileReference



38
39
40
41
42
# File 'lib/xcode/pbx_file_reference.rb', line 38

def initialize(attributes, file_type = nil)
  @file_type = file_type
  @id = Xcode.register(self)
  @attributes = attributes
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/xcode/pbx_file_reference.rb', line 4

def id
  @id
end

Class Method Details

.file_reference_for_file(file) ⇒ Object



6
7
8
9
# File 'lib/xcode/pbx_file_reference.rb', line 6

def self.file_reference_for_file(file)
  @file_references ||= {}
  @file_references[File.expand_path(file)] || raise("cannot find file ref for #{file}")
end

.new_from_file(file, file_type = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/xcode/pbx_file_reference.rb', line 11

def self.new_from_file(file, file_type = nil)
  attributes = {}
  attributes["path"] = File.basename(file)
  case File.extname(file)
  when ".h"
    attributes.merge! "lastKnownFileType" => "sourcecode.c.h", "fileEncoding" => "4"
  when ".m"
    attributes.merge! "lastKnownFileType" => "sourcecode.c.objc", "fileEncoding" => "4"
  when ".a"
    attributes.merge! "lastKnownFileType" => "archive.ar", "fileEncoding" => "4"
  when ".plist"
    attributes.merge! "lastKnownFileType" => "text.plist.xml", "fileEncoding" => "4"
  when ".strings"
    attributes.merge! "lastKnownFileType" => "text.plist.strings", "fileEncoding" => "10"
  when ".png", ".tiff", ".jpg", ".jpeg"
    ext = File.extname(file)
    ext = ".jpeg" if ext == ".jpg"
    attributes.merge! "lastKnownFileType" => "image#{ext}"
  else
    attributes.merge! "lastKnownFileType" => "file"
  end
  instance = new attributes, file_type
  @file_references ||= {}
  @file_references[File.expand_path(file)] = instance
  instance
end

Instance Method Details

#attributesObject



44
45
46
47
48
49
50
# File 'lib/xcode/pbx_file_reference.rb', line 44

def attributes
  result = {
    "isa" => isa,
    "sourceTree" => "<group>"
  }.merge @attributes
  result
end

#create_pbx_build_fileObject



56
57
58
# File 'lib/xcode/pbx_file_reference.rb', line 56

def create_pbx_build_file
  Xcode::PBXBuildFile.new(self, @file_type)
end

#isaObject



52
53
54
# File 'lib/xcode/pbx_file_reference.rb', line 52

def isa
  "PBXFileReference"
end