Class: String
Instance Method Summary collapse
Instance Method Details
#constantize ⇒ Object
22 23 24 |
# File 'lib/csv_record/helpers.rb', line 22 def constantize self.split('_').map { |w| w.capitalize }.join end |
#to_class ⇒ Object
25 26 27 |
# File 'lib/csv_record/helpers.rb', line 25 def to_class Object.const_get self.constantize.singularize end |
#underscore ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/csv_record/helpers.rb', line 28 def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |