Module: Gemmy::Patches::StringPatch::InstanceMethods::Alpha
- Defined in:
- lib/gemmy/patches/string_patch.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#alpha(opts = {}) ⇒ Object
Gsub non-alphabetical characters.
- #alpha!(opts = {}) ⇒ Object
Class Method Details
._alpha(string, bang: false, strip_whitespace: false) ⇒ Object
40 41 42 43 44 |
# File 'lib/gemmy/patches/string_patch.rb', line 40 def self._alpha(string, bang: false, strip_whitespace: false) fn = bang ? :gsub! : :gsub regex = /[^a-zA-Z0-9#{'\s' unless strip_whitespace}]/ string.send fn, regex, '' end |
Instance Method Details
#alpha(opts = {}) ⇒ Object
Gsub non-alphabetical characters
52 53 54 55 56 57 |
# File 'lib/gemmy/patches/string_patch.rb', line 52 def alpha(opts={}) Gemmy.patch("string/i/alpha")._alpha( self, opts ) end |
#alpha!(opts = {}) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/gemmy/patches/string_patch.rb', line 45 def alpha!(opts={}) Gemmy.patch("string/i/alpha")._alpha( self, opts.merge(bang: true) ) end |