Sha256: 9d79b013b1556143c3cb436264b654d0ee4e36304acaaae67f5c93ade6774c8f
Contents?: true
Size: 342 Bytes
Versions: 1
Compression:
Stored size: 342 Bytes
Contents
# Extend the Ruby String class class String ## # Returns the snake_case version of a word # # Example: # # "IndexController".snake_case = "index_controller" def snake_case gsub!(/::/, '/') gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2') gsub!(/([a-z\d])([A-Z])/, '\1_\2') tr!('-', '_') downcase! self end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rapid_runty-0.1.2 | lib/rapid_runty/util.rb |