Sha256: 7681b0017be338c2b03d6304bb22389953b4232dd081db4ebc3a170638d20c25
Contents?: true
Size: 962 Bytes
Versions: 2
Compression:
Stored size: 962 Bytes
Contents
# The methods below were snatch right outta Rails' ActiveSupport, so we don't have to depend on it.. # See http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-camelize class String # File activesupport/lib/active_support/inflector/methods.rb, line 48 def underscore(camel_cased_word) word = camel_cased_word.to_s.dup word.gsub!(/::/, '/') word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') word.gsub!(/([a-z\d])([A-Z])/,'\1_\2') word.tr!("-", "_") word.downcase! word end # File activesupport/lib/active_support/inflector/methods.rb, line 28 def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true) if first_letter_in_uppercase lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } else lower_case_and_underscored_word.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..-1] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wordnik-0.3.1 | lib/wordnik/monkey_patches.rb |
wordnik-0.3.0 | lib/wordnik/monkey_patches.rb |