Module: Xcodeproj::Project::Object::CaseConverter
- Defined in:
- lib/xcodeproj/project/case_converter.rb
Overview
Converts between camel case names used in the xcodeproj plist files and the ruby symbols used to represent them.
Class Method Summary collapse
-
.convert_to_plist(name, type = nil) ⇒ String
The plist equivalent of the given Ruby name.
-
.convert_to_ruby(name) ⇒ Symbol
The Ruby equivalent of the given plist name.
-
.plist_cache ⇒ Hash
A cache for the conversion to the Plist format.
Class Method Details
.convert_to_plist(name, type = nil) ⇒ String
Returns The plist equivalent of the given Ruby name.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/xcodeproj/project/case_converter.rb', line 20 def self.convert_to_plist(name, type = nil) case name when :remote_global_id_string 'remoteGlobalIDString' else if type == :lower cache = plist_cache[:lower] ||= {} cache[name] ||= camelize(name, :uppercase_first_letter => false) else cache = plist_cache[:normal] ||= {} cache[name] ||= camelize(name) end end end |
.convert_to_ruby(name) ⇒ Symbol
Returns The Ruby equivalent of the given plist name.
74 75 76 |
# File 'lib/xcodeproj/project/case_converter.rb', line 74 def self.convert_to_ruby(name) underscore(name.to_s).to_sym end |
.plist_cache ⇒ Hash
Note:
A cache is used because this operation is performed for each attribute of the project when it is saved and caching it has an important performance benefit.
Returns A cache for the conversion to the Plist format.
84 85 86 |
# File 'lib/xcodeproj/project/case_converter.rb', line 84 def self.plist_cache @plist_cache ||= {} end |