Sha256: 918c6a9a5e2a6a4fe179229e7aa3a2046e752a61b61ffd2e9afa1f824c50764e

Contents?: true

Size: 654 Bytes

Versions: 14

Compression:

Stored size: 654 Bytes

Contents

require 'json'

class String
  
  #
  # Xcode format for a string is exactly the same as you would expect in JSON
  # 
  def to_xcplist
    to_json
  end
  
  #
  # 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.
  # 
  # @return [String] convert camel-cased words, generating underscored, ruby
  #   friend names.
  def underscore
    self.gsub(/::/, '/').
      gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
      gsub(/([a-z\d])([A-Z])/,'\1_\2').
      tr("-", "_").
      downcase
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
xcoder-0.1.18 lib/xcode/core_ext/string.rb
xcoder-0.1.15 lib/xcode/core_ext/string.rb
xcoder-0.1.14 lib/xcode/core_ext/string.rb
xcoder-0.1.13 lib/xcode/core_ext/string.rb
xcoder-0.1.12 lib/xcode/core_ext/string.rb
xcoder-0.1.11 lib/xcode/core_ext/string.rb
xcoder-0.1.10 lib/xcode/core_ext/string.rb
xcoder-0.1.9 lib/xcode/core_ext/string.rb
xcoder-0.1.8 lib/xcode/core_ext/string.rb
xcoder-0.1.7 lib/xcode/core_ext/string.rb
xcoder-0.1.6 lib/xcode/core_ext/string.rb
xcoder-0.1.4 lib/xcode/core_ext/string.rb
xcoder-0.1.3 lib/xcode/core_ext/string.rb
xcoder-0.1.2 lib/xcode/core_ext/string.rb