Class: String
Instance Method Summary collapse
Instance Method Details
#sanitize_path! ⇒ Object
14 15 16 17 |
# File 'lib/pup/utilities/string.rb', line 14 def sanitize_path! replace(self[0..-2]) if self[-1] == "/" replace("/" + self) if self[0] != "/" end |
#to_camelcase ⇒ Object
2 3 4 |
# File 'lib/pup/utilities/string.rb', line 2 def to_camelcase split("_").map(&:capitalize).join end |
#to_snakecase ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/pup/utilities/string.rb', line 6 def to_snakecase gsub(/::/, "/"). gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr("-", "_"). downcase end |