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

Version Path
toolhound-ruby-1.0.37 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.36 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.35 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.34 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.33 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.32 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.31 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.30 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.29 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.28 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.27 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.26 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.25 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.24 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.23 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.22 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.21 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.20 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.19 lib/toolhound-ruby/core_ext/string.rb
toolhound-ruby-1.0.18 lib/toolhound-ruby/core_ext/string.rb