Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/xcode/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#to_xcplistObject

Xcode format for a string is exactly the same as you would expect in JSON



8
9
10
# File 'lib/xcode/core_ext/string.rb', line 8

def to_xcplist
  to_json
end

#underscoreString

Similar to ActiveRecord’s underscore method. Return a string version underscored. This is used specifically to convert the property keys into Ruby friendly names as they are used for creating method names.

Returns:

  • (String)

    convert camel-cased words, generating underscored, ruby friend names.



19
20
21
22
23
24
25
# File 'lib/xcode/core_ext/string.rb', line 19

def underscore
  self.gsub(/::/, '/').
    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    downcase
end