Class: FileRef

Inherits:
Object
  • Object
show all
Defined in:
lib/unigunkan/fileref.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ FileRef

Returns a new instance of FileRef.



4
5
6
7
8
9
10
11
# File 'lib/unigunkan/fileref.rb', line 4

def initialize(hash)
  @id = SecureRandom.hex(12)
  @name = hash[:name]
  @last_known_type = hash[:last_known_type]
  @path = hash[:path]
  @source_tree = hash[:source_tree]
  @file_encoding = hash[:file_encoding]
end

Instance Attribute Details

#file_encodingObject

Returns the value of attribute file_encoding.



2
3
4
# File 'lib/unigunkan/fileref.rb', line 2

def file_encoding
  @file_encoding
end

#idObject

Returns the value of attribute id.



2
3
4
# File 'lib/unigunkan/fileref.rb', line 2

def id
  @id
end

#last_known_typeObject

Returns the value of attribute last_known_type.



2
3
4
# File 'lib/unigunkan/fileref.rb', line 2

def last_known_type
  @last_known_type
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/unigunkan/fileref.rb', line 2

def name
  @name
end

#pathObject

Returns the value of attribute path.



2
3
4
# File 'lib/unigunkan/fileref.rb', line 2

def path
  @path
end

#source_treeObject

Returns the value of attribute source_tree.



2
3
4
# File 'lib/unigunkan/fileref.rb', line 2

def source_tree
  @source_tree
end

Class Method Details

.file_group(filename) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/unigunkan/fileref.rb', line 39

def self.file_group(filename)
  ext = filename.split(".").last
  case ext
  when "dylib"
    return "Frameworks"
  end
end

Instance Method Details

#build_fileObject



34
35
36
37
# File 'lib/unigunkan/fileref.rb', line 34

def build_file
  @build_file = BuildFile.new(self) if !@build_file
  return @build_file
end

#fieldsObject



13
14
15
16
17
18
19
20
# File 'lib/unigunkan/fileref.rb', line 13

def fields
  last_known_type = @last_known_type
  last_known_type = "\"#{last_known_type}\"" if last_known_type == "compiled.mach-o.dylib"

  elements = ["isa = PBXFileReference", "lastKnownType = #{last_known_type}", "name = #{@name}", "path = #{@path}", "sourceTree = #{@source_tree}"]
  elements << "fileEncoding = #{@file_encoding}" if @file_encoding
  elements.map{|a| "#{a};"}.join(" ")
end

#groupObject



30
31
32
# File 'lib/unigunkan/fileref.rb', line 30

def group
  FileRef.file_group(self.name)
end

#keyObject



22
23
24
# File 'lib/unigunkan/fileref.rb', line 22

def key
  "#{@id} /* #{@name} */"
end

#to_sObject



26
27
28
# File 'lib/unigunkan/fileref.rb', line 26

def to_s
  "#{self.key} = {#{self.fields}};"
end