Code cleanup, improved String.to_filename.

This commit is contained in:
Martin Edenhofer 2015-12-16 22:47:10 +01:00
parent 644ecc6ef8
commit 9a702b528c
2 changed files with 7 additions and 4 deletions

View file

@ -32,7 +32,10 @@ class String
def to_filename def to_filename
camel_cased_word = "#{self}" camel_cased_word = "#{self}"
camel_cased_word.gsub(/::/, '/').downcase camel_cased_word.gsub(/::/, '/')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr('-', '_').downcase
end end
=begin =begin