Module: Normatron::Filters::SquishFilter

Defined in:
lib/normatron/filters/squish_filter.rb

Class Method Summary collapse

Class Method Details

.evaluate(input) ⇒ String

Strip input, remove line-breaks and multiple spaces.

Examples:

SquishFilter.evaluate("   the simpsons   ") #=> "the simpsons"
SquishFilter.evaluate("family      guy")    #=> "family guy"
SquishFilter.evaluate("the \n simpsons")    #=> "the simpsons"
SquishFilter.evaluate("the\nsimpsons")      #=> "the simpsons"

Using as ActiveRecord::Base normalizer

normalize :attribute, :with => [:custom_filter, :squish]

Parameters:

  • input (String)

    A character sequence

Returns:

  • (String)

    The clean character sequence or the object itself

See Also:



23
24
25
# File 'lib/normatron/filters/squish_filter.rb', line 23

def self.evaluate(input)
  input.kind_of?(String) ? input.squish : input
end