Sha256: 097b41e93a870a9d9b4b9cc5648b4a83e56bdb2e1f42b3fbd460bf1751e809c2
Contents?: true
Size: 1.04 KB
Versions: 33
Compression:
Stored size: 1.04 KB
Contents
class String # def underscore() # camel_cased_word = self # acronym_regex = /#{["REST"].join("|")}/ # return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/ # word = camel_cased_word.to_s.gsub('::'.freeze, '/'.freeze) # word.gsub!(/(?:(?<=([A-Za-z\d]))|\b)(#{acronym_regex})(?=\b|[^a-z])/) { "#{$1 && '_'.freeze }#{$2.downcase}" } # word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'.freeze) # word.gsub!(/([a-z\d])([A-Z])/, '\1_\2'.freeze) # word.tr!("-".freeze, "_".freeze) # word.downcase! # word # end # # def camelize(term, uppercase_first_letter = true) # string = term.to_s # if uppercase_first_letter # string = string.sub(/^[a-z\d]*/) { |match| inflections.acronyms[match] || match.capitalize } # else # string = string.sub(/^(?:#{inflections.acronym_regex}(?=\b|[A-Z_])|\w)/) { |match| match.downcase } # end # string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{inflections.acronyms[$2] || $2.capitalize}" } # string.gsub!('/'.freeze, '::'.freeze) # string # end end
Version data entries
33 entries across 33 versions & 1 rubygems