Module: UnicodeAlphanumeric
- Defined in:
- lib/unicode_alphanumeric.rb
Class Method Summary collapse
- .filter(str, options = {}) ⇒ Object
- .map(str, options = {}) ⇒ Object
- .replace(str, replacement, options = {}) ⇒ Object
- .scan(str, options = {}) ⇒ Object
Class Method Details
.filter(str, options = {}) ⇒ Object
4 5 6 |
# File 'lib/unicode_alphanumeric.rb', line 4 def self.filter(str, = {}) replace(str, '', ) end |
.map(str, options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/unicode_alphanumeric.rb', line 22 def self.map(str, = {}) str.gsub(ascii_regex()) do |char| alphanumeric?(char, ) ? char : yield(char) end end |
.replace(str, replacement, options = {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/unicode_alphanumeric.rb', line 8 def self.replace(str, replacement, = {}) str.gsub(ascii_regex()) do |char| alphanumeric?(char, ) ? char : replacement end end |
.scan(str, options = {}) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/unicode_alphanumeric.rb', line 14 def self.scan(str, = {}) non_alphanumeric = [] str.scan(ascii_regex()) do |char| non_alphanumeric << char if !alphanumeric?(char, ) end non_alphanumeric end |