Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 17 lines (12 sloc) 0.387 kb
#!/usr/bin/env ruby
#
# Converts camelCase to snake_case in the given input.
#
# Written in 2010 by Suraj N. Kurapati <https://github.com/sunaku>
input = ARGF.read
# remove the 'a' argument prefix
input.gsub!(/\ba([A-Z])([a-z]+)/) { $1.downcase + $2 }
# convert camel case to snake case
while input.gsub!(/\b([a-z_]+)([A-Z])([a-z]+)/) { $1 + '_' + $2.downcase + $3 }
end
print input
Jump to Line
Something went wrong with that request. Please try again.