class.rb 385 B

123456789101112131415
  1. class Class
  2. def to_app_model_url
  3. camel_cased_word = to_s
  4. camel_cased_word.gsub(/::/, '_')
  5. .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
  6. .gsub(/([a-z\d])([A-Z])/, '\1_\2')
  7. .tr('-', '_')
  8. .downcase
  9. end
  10. def to_app_model
  11. camel_cased_word = to_s
  12. camel_cased_word.gsub(/::/, '').to_sym
  13. end
  14. end