Module: Sem4r::CoreExtensions::String

Included in:
String
Defined in:
lib/sem4r/extensions.rb

Overview

Rails’ ActiveSupport

Instance Method Summary collapse

Instance Method Details

#camel_caseObject



70
71
72
# File 'lib/sem4r/extensions.rb', line 70

def camel_case
  self.gsub(/_([a-z])/) { $1.upcase }
end

#underscoreObject

:nodoc:



61
62
63
64
65
66
67
68
# File 'lib/sem4r/extensions.rb', line 61

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