vishalzambre/ecwid_api

View on GitHub
lib/ext/string.rb

Summary

Maintainability
A
0 mins
Test Coverage
class String
  def camel_case
    split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
  end unless method_defined?(:camel_case)

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