Class: String

Inherits:
Object show all
Defined in:
lib/kitchen/patches/string.rb

Overview

Monkey patches for String

Direct Known Subclasses

Kitchen::I18nString

Instance Method Summary collapse

Instance Method Details

#kebab_caseString

Transform self to kebab case, returning a new string Example: “Star Wars: The Empire Strikes Back” -> “star-wars-the-empire-strikes-back”

Returns:



19
20
21
# File 'lib/kitchen/patches/string.rb', line 19

def kebab_case
  strip.downcase.gsub(/®/, ' r').gsub(/[^(\w\s)\-]/, '').gsub(/\s/, '-')
end

#uncapitalizeString

Downcases the first letter of self, returning a new string

Returns:



10
11
12
# File 'lib/kitchen/patches/string.rb', line 10

def uncapitalize
  sub(/^[A-Z]/, &:downcase)
end