Parent

Class/Module Index [+]

Quicksearch

Hashie::Rash

Protected Instance Methods

underscore_string(str) click to toggle source

converts a camel_cased string to a underscore string subs spaces with underscores, strips whitespace Same way ActiveSupport does string.underscore

# File lib/hashie/rash.rb, line 31
def underscore_string(str)
  str.to_s.strip.
    gsub(' ', '_').
    gsub(/::/, '/').
    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    squeeze("_").
    downcase
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.