Module: Normatron::Filters::CapitalizeFilter

Extended by:
Helpers
Defined in:
lib/normatron/filters/capitalize_filter.rb

Overview

Makes the first character uppercase and all remaining characters lowercase.

Examples:

Out of box

CapitalizeFilter.call("KEEP IT SIMPLE")  #=> "Keep it simple"
CapitalizeFilter.call("keep it simple")  #=> "Keep it simple"
CapitalizeFilter.call(" KEEP IT SIMPLE") #=> " keep it simple"

Using as model normalizer

normalize :attribute_a, :with => :capitalize
normalize :attribute_b, :with => [:custom_filter, :capitalize]

See Also:

Class Method Summary collapse

Methods included from Helpers

acronym_regex, acronyms, evaluate_regexp, inflections, mb_send

Class Method Details

.call(input) ⇒ String

Performs input conversion according to filter requirements.

This method returns the object itself when the first argument is not a String.

Parameters:

  • input (String)

    The String to be filtered

Returns:

  • (String)

    A new capitalized String


30
31
32
# File 'lib/normatron/filters/capitalize_filter.rb', line 30

def self.call(input)
  input.kind_of?(String) ? mb_send(:capitalize, input) : input
end