Class: String
Overview
Monkey patches for String
Direct Known Subclasses
Instance Method Summary collapse
-
#kebab_case ⇒ String
Transform self to kebab case, returning a new string Example: “Star Wars: The Empire Strikes Back” -> “star-wars-the-empire-strikes-back”.
-
#uncapitalize ⇒ String
Downcases the first letter of self, returning a new string.
Instance Method Details
#kebab_case ⇒ String
Transform self to kebab case, returning a new string Example: “Star Wars: The Empire Strikes Back” -> “star-wars-the-empire-strikes-back”
19 20 21 |
# File 'lib/kitchen/patches/string.rb', line 19 def kebab_case strip.downcase.gsub(/®/, ' r').gsub(/[^(\w\s)\-]/, '').gsub(/\s/, '-') end |
#uncapitalize ⇒ String
Downcases the first letter of self, returning a new string
10 11 12 |
# File 'lib/kitchen/patches/string.rb', line 10 def uncapitalize sub(/^[A-Z]/, &:downcase) end |