Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/lightning/utils/string.rb
Instance Method Summary collapse
Instance Method Details
#camel ⇒ Object
4 5 6 |
# File 'lib/lightning/utils/string.rb', line 4 def camel split('_').map { |w| w[0].upcase + w[1..-1] }.join end |
#snake ⇒ Object
8 9 10 11 12 13 |
# File 'lib/lightning/utils/string.rb', line 8 def snake gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end |