module Gemmy::Patches::StringPatch::InstanceMethods::Alpha

Public Class Methods

_alpha(string, bang: false, strip_whitespace: false) click to toggle source
# File lib/gemmy/patches/string_patch.rb, line 46
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

Public Instance Methods

alpha(opts={}) click to toggle source

Gsub non-alphabetical characters

# File lib/gemmy/patches/string_patch.rb, line 58
def alpha(opts={})
  Gemmy.patch("string/i/alpha")._alpha(
    self,
    opts
  )
end
alpha!(opts={}) click to toggle source
# File lib/gemmy/patches/string_patch.rb, line 51
def alpha!(opts={})
  Gemmy.patch("string/i/alpha")._alpha(
    self,
    opts.merge(bang: true)
  )
end