Module: NormalizeString
- Defined in:
- lib/normalize_string.rb
Class Method Summary collapse
- .normalize(string) ⇒ Object
- .remove_emoji_and_normalize(string, keep_emoji_when_empty: false) ⇒ Object
Class Method Details
.normalize(string) ⇒ Object
4 5 6 7 8 |
# File 'lib/normalize_string.rb', line 4 def self.normalize(string) return unless string.present? AnyAscii.transliterate(string) end |
.remove_emoji_and_normalize(string, keep_emoji_when_empty: false) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/normalize_string.rb', line 10 def self.remove_emoji_and_normalize(string, keep_emoji_when_empty: false) return unless string.present? result = AnyAscii.transliterate(string.gsub(/\p{So}/, '')) return result if result.present? || !keep_emoji_when_empty normalize(string) end |