module Normalizy::Filters::Strip

Public Class Methods

call(input, options = {}) click to toggle source
# File lib/normalizy/filters/strip.rb, line 6
def self.call(input, options = {})
  return input unless input.is_a?(String)

  regex = {
    both:  '\A\s*|\s*\z',
    left:  '\A\s*',
    right: '\s*\z'
  }[options[:side] || :both]

  input.gsub Regexp.new(/#{regex}/), ''
end