Class: PBXProject::PBXTypes::ISAType
- Inherits:
-
Object
- Object
- PBXProject::PBXTypes::ISAType
- Defined in:
- lib/pbxproject/pbxtypes.rb
Direct Known Subclasses
PBXBuildFile, PBXContainerItemProxy, PBXFileReference, PBXFrameworksBuildPhase, PBXGroup, PBXHeadersBuildPhase, PBXLegacyTarget, PBXNativeTarget, PBXProject, PBXReferenceProxy, PBXResourcesBuildPhase, PBXShellScriptBuildPhase, PBXSourcesBuildPhase, PBXTargetDependency, PBXVariantGroup, XCBuildConfiguration, XCConfigurationList, XCVersionGroup
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#guid ⇒ Object
Returns the value of attribute guid.
-
#isa ⇒ Object
Returns the value of attribute isa.
Class Method Summary collapse
Instance Method Summary collapse
- #_pbx_format ⇒ Object
- #_pbx_indent(ind = 0) ⇒ Object
- #_pbx_newline ⇒ Object
- #basic_value(value = nil, comment = nil) ⇒ Object
- #hashify(to_hash) ⇒ Object
-
#initialize(args = {}) ⇒ ISAType
constructor
A new instance of ISAType.
- #to_pbx(ind = 0) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ ISAType
Returns a new instance of ISAType.
26 27 28 29 30 31 32 33 |
# File 'lib/pbxproject/pbxtypes.rb', line 26 def initialize args = {} @isa = basic_value(self.class.name.split("::").last) @guid = hashify(self) args.each do |k,v| instance_variable_set("@#{k}", basic_value(v)) unless v.nil? end end |
Instance Attribute Details
#comment ⇒ Object
Returns the value of attribute comment.
24 25 26 |
# File 'lib/pbxproject/pbxtypes.rb', line 24 def comment @comment end |
#guid ⇒ Object
Returns the value of attribute guid.
24 25 26 |
# File 'lib/pbxproject/pbxtypes.rb', line 24 def guid @guid end |
#isa ⇒ Object
Returns the value of attribute isa.
24 25 26 |
# File 'lib/pbxproject/pbxtypes.rb', line 24 def isa @isa end |
Class Method Details
.has_fields(*fields) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pbxproject/pbxtypes.rb', line 46 def self.has_fields(*fields) _fields = [] fields.each do |f| _fields.push f.id2name define_method(f) do instance_variable_get("@#{f}") end define_method("#{f}=") do |val| instance_variable_set("@#{f}", val) end end define_method("pbxfields") do _fields end end |
.has_format(format) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/pbxproject/pbxtypes.rb', line 65 def self.has_format(format) _format = format define_method("format") do _format end end |
Instance Method Details
#_pbx_format ⇒ Object
77 78 79 80 |
# File 'lib/pbxproject/pbxtypes.rb', line 77 def _pbx_format return nil unless defined? format format end |
#_pbx_indent(ind = 0) ⇒ Object
73 74 75 |
# File 'lib/pbxproject/pbxtypes.rb', line 73 def _pbx_indent(ind = 0) "\t" * ind end |
#_pbx_newline ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/pbxproject/pbxtypes.rb', line 82 def _pbx_newline case _pbx_format when :oneline nil else "\n" end end |
#basic_value(value = nil, comment = nil) ⇒ Object
35 36 37 38 |
# File 'lib/pbxproject/pbxtypes.rb', line 35 def basic_value(value = nil, comment = nil) # { :value => value, :comment => comment } BasicValue.new :value => value, :comment => comment end |
#hashify(to_hash) ⇒ Object
40 41 42 43 44 |
# File 'lib/pbxproject/pbxtypes.rb', line 40 def hashify to_hash # example ex = 'C01713D713462F35007665FA' "OEF" + (Digest::SHA1.hexdigest to_hash.to_s).upcase[4..ex.length] end |
#to_pbx(ind = 0) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/pbxproject/pbxtypes.rb', line 91 def to_pbx(ind = 0) pbx = '' pbx += _pbx_indent(ind) + "#{@guid}" pbx += " /* #{@comment} */" if @comment pbx += " = {%s" % _pbx_newline ind += 1 # PBX fields pbxfields.each do |fld| field = self.instance_variable_get("@#{fld}") case field.class.name when "String" pbx += (_pbx_format == :multiline ? _pbx_indent(ind) : "") + "%s = %s;%s%s" % [fld, field, (_pbx_newline == nil ? " " : ""),_pbx_newline] when 'PBXProject::PBXTypes::BasicValue' pbx += (_pbx_format == :multiline ? _pbx_indent(ind) : "") + "%s = %s;%s%s" % [fld, field.to_pbx, (_pbx_newline == nil ? " " : ""), _pbx_newline] when "Array" pbx += _pbx_indent(ind) + "%s = (%s" % [fld, _pbx_newline] ind += 1 field.each do |item| pbx += _pbx_indent(ind) + "%s,%s" % [item.to_pbx, _pbx_newline] end ind -= 1 pbx += _pbx_indent(ind) + ");%s" % _pbx_newline when "NilClass" when "Hash" pbx += _pbx_indent(ind) + "%s = {%s" % [fld, _pbx_newline] ind += 1 field.each do |name, d| case d.class.name when "PBXProject::PBXTypes::BasicValue" pbx += _pbx_indent(ind) + "%s = %s;%s%s" % [name, d.to_pbx, (_pbx_newline == nil ? " " : ""), _pbx_newline] when "Array" pbx += _pbx_indent(ind) + "%s = (%s" % [name, _pbx_newline] ind += 1 d.each do |item| pbx += _pbx_indent(ind) + "%s,%s" % [item.to_pbx, _pbx_newline] end ind -= 1 pbx += _pbx_indent(ind) + ");%s" % _pbx_newline end end ind -= 1 pbx += _pbx_indent(ind) + "};%s" % _pbx_newline else puts "WHAT? #{field.class}" puts "#{field}" end end ind -= 1 # ind.times{print"\t"}; pbx += "};%s" % _pbx_newline if (_pbx_newline) pbx += "\t" * ind + "};\n" else pbx += "};\n" end pbx end |