module BrregGrunndata::Utils::StringExt
Constants
- NAMESPACE_SEPARATOR
- UNDERSCORE_DIVISION_TARGET
- UNDERSCORE_SEPARATOR
Public Instance Methods
underscore()
click to toggle source
Underscores a string
# File lib/brreg_grunndata/utils.rb, line 85 def underscore new_string = gsub(NAMESPACE_SEPARATOR, UNDERSCORE_SEPARATOR) new_string.gsub!(/([A-Z\d]+)([A-Z][a-z])/, UNDERSCORE_DIVISION_TARGET) new_string.gsub!(/([a-z\d])([A-Z])/, UNDERSCORE_DIVISION_TARGET) new_string.gsub!(/[[:space:]]|\-/, UNDERSCORE_DIVISION_TARGET) new_string.downcase! new_string end