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] ||= name.to_s.camelize(:lower) else cache = plist_cache[:normal] ||= {} cache[name] ||= name.to_s.camelize end end end |
.convert_to_ruby(name) ⇒ Symbol
Returns The Ruby equivalent of the given plist name.
43 44 45 |
# File 'lib/xcodeproj/project/case_converter.rb', line 43 def self.convert_to_ruby(name) name.to_s.underscore.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.
53 54 55 |
# File 'lib/xcodeproj/project/case_converter.rb', line 53 def self.plist_cache @plist_cache ||= {} end |