Module: DIY::Infl

Defined in:
lib/diy.rb

Overview

:nodoc:#

Class Method Summary collapse

Class Method Details

.camelize(lower_case_and_underscored_word) ⇒ Object

Ganked this from Inflector:



395
396
397
# File 'lib/diy.rb', line 395

def self.camelize(lower_case_and_underscored_word) 
  lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
end

.underscore(camel_cased_word) ⇒ Object

Ganked this from Inflector:



399
400
401
# File 'lib/diy.rb', line 399

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