Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/finest/builder.rb

Overview

Add snake case in String

Instance Method Summary collapse

Instance Method Details

#snake_caseObject



7
8
9
# File 'lib/finest/builder.rb', line 7

def snake_case
  length > 7 ? strip.gsub(/(\w[A-Z]|\s\S)/) { |e| "#{e[0].strip}_#{e[1].strip.downcase}" }.downcase : strip.downcase
end