ara.t.howard / noaa.gov wrote:
> def snake_case string
>   return string unless string =~ %r/[A-Z]/
>   reversed_words = string.reverse.scan(%r/[A-Z]+|[^A-Z]*[A-Z]+?|[^A-Z]+/)
>   reversed_words.reverse.map{|word| 
> word.reverse.downcase}.join('_').gsub(%r/_+/,'_')

I'm not sure you want to label these as bugs:

   "FOO_Bar" => "fo_o_bar"
   "FOO_bar" => "fo_o_bar"

But this probably is:

   "FOO_BAR" => "fo_o_bar"


Cheers,
Daniel