Skip to content

@timcharper /string.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
to_underscore implementation
class String
# ruby mutation methods have the expectation to return self if a mutation occurred, nil otherwise. (see http://www.ruby-doc.org/core-1.9.3/String.html#method-i-gsub-21)
def to_underscore!
g = gsub!(/(.)([A-Z])/,'\1_\2'); d = downcase!
g || d
end
def to_underscore
dup.tap { |s| s.to_underscore! }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.