Module: Normatron::Filters::StripFilter
- Extended by:
- Helpers
- Defined in:
- lib/normatron/filters/strip_filter.rb
Overview
Removes traling and leading spaces.
Class Method Summary collapse
-
.call(input, edges = :LR) ⇒ String
Performs input conversion according to filter requirements.
Methods included from Helpers
acronym_regex, acronyms, evaluate_regexp, inflections, mb_send
Class Method Details
.call(input, edges = :LR) ⇒ String
Performs input conversion according to filter requirements.
This method returns the object itself when the first argument is not a String.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/normatron/filters/strip_filter.rb', line 36 def self.call(input, edges=:LR) return input unless input.kind_of?(String) regex_string = case edges when :L '\A\s*' when :R '\s*\z' when :LR '\A\s*|\s*\z' end regex = Regexp.new(/#{regex_string}/) input.gsub(regex, '') end |