Class: String

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.underscore(camel_cased_word) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/nextbus/string_extensions.rb', line 7

def self.underscore(camel_cased_word)
  camel_cased_word.to_s.gsub(/::/, '/').
    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr(" ", "_").
    tr("-", "_").
    downcase
end

Instance Method Details

#underscoreObject



3
4
5
# File 'lib/nextbus/string_extensions.rb', line 3

def underscore
  self.class.underscore(self)
end