Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/speaking_url/core_ext/string/inflections.rb
Instance Method Summary collapse
- #downcase ⇒ Object
- #original_downcase ⇒ Object
- #original_upcase ⇒ Object
-
#unumlaut ⇒ Object
Romanizes all German Umlaut characters.
- #upcase ⇒ Object
-
#urlify ⇒ Object
Replaces all white space and special characters of a String with dashes, to make it a valid url segment:.
Instance Method Details
#downcase ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/speaking_url/core_ext/string/inflections.rb', line 16 def downcase translations = [ ["Ä", "ä"], ["Ö", "ö"], ["Ü", "ü"] ] res = self.original_downcase translations.each do |f,t| res.gsub!(f,t) end res end |
#original_downcase ⇒ Object
4 |
# File 'lib/speaking_url/core_ext/string/inflections.rb', line 4 alias_method :original_downcase, :downcase |
#original_upcase ⇒ Object
5 |
# File 'lib/speaking_url/core_ext/string/inflections.rb', line 5 alias_method :original_upcase, :upcase |
#unumlaut ⇒ Object
Romanizes all German Umlaut characters
"Füße".unumlaut # => "Fuesse"
36 37 38 39 40 41 42 43 |
# File 'lib/speaking_url/core_ext/string/inflections.rb', line 36 def unumlaut res = self translations = [ ["Ä", "AE"], ["ä", "ae"], ["Ö", "OE"], ["ö", "oe"], ["Ü", "UE"], ["ü", "ue"], ["ß", "ss"] ] translations.each do |f,t| res.gsub!(f,t) end res end |
#upcase ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/speaking_url/core_ext/string/inflections.rb', line 7 def upcase translations = [ ["ä", "Ä"], ["ö", "Ö"], ["ü", "Ü"], ["ß", "SS"] ] res = self.original_upcase translations.each do |f,t| res.gsub!(f,t) end res end |
#urlify ⇒ Object
Replaces all white space and special characters of a String with dashes, to make it a valid url segment:
"** Dr. Jekyll and Mr. Hyde ++" # => "Dr-Jekyll-and-Mr-Hyde"
29 30 31 |
# File 'lib/speaking_url/core_ext/string/inflections.rb', line 29 def urlify self.split(/\W+/).reject(&:blank?).join('-') end |