Module: Nori::StringUtils
- Defined in:
- lib/nori/string_utils.rb
Class Method Summary collapse
-
.snakecase(inputstring) ⇒ String
Converts a string to snake case.
Class Method Details
.snakecase(inputstring) ⇒ String
Converts a string to snake case.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/nori/string_utils.rb', line 7 def self.snakecase(inputstring) str = inputstring.dup str.gsub!(/::/, '/') str.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2') str.gsub!(/([a-z\d])([A-Z])/, '\1_\2') str.tr!(".", "_") str.tr!("-", "_") str.downcase! str end |