Module: Dewey::Utils
- Defined in:
- lib/dewey/utils.rb
Overview
:nodoc:
Class Method Summary collapse
-
.slug(string) ⇒ Object
Perform string escaping for Atom slugs.
Class Method Details
.slug(string) ⇒ Object
Perform string escaping for Atom slugs
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/dewey/utils.rb', line 4 def slug(string) string.chars.to_a.map do |char| decimal = char.unpack('U').join('').to_i if decimal < 32 || decimal > 126 || decimal == 37 char = "%#{char.unpack('H2').join('%').upcase}" end char end.join('') end |