Class: String

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

Overview

Monkey patch for underscores.

Instance Method Summary collapse

Instance Method Details

#underscoreObject



5
6
7
8
9
10
11
# File 'lib/hash.rb', line 5

def underscore
  gsub(/::/, '/')
    .gsub(/([a-z\d])([A-Z])/) do
    "#{Regexp.last_match(1)}_#{Regexp.last_match(2)}"
  end
    .downcase
end