Class: System::String
Instance Method Summary collapse
-
#classify ⇒ Object
Gets the constant when it is defined that corresponds to this string.
-
#underscore ⇒ Object
converts a camel cased word to an underscored word.
Instance Method Details
#classify ⇒ Object
Gets the constant when it is defined that corresponds to this string
15 16 17 |
# File 'lib/core_ext/system/string.rb', line 15 def classify Object.const_get self end |
#underscore ⇒ Object
converts a camel cased word to an underscored word
6 7 8 9 10 11 12 |
# File 'lib/core_ext/system/string.rb', line 6 def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |