module Blur::TextHelper

Constants

VERSION

Public Instance Methods

pluralize(count, word) click to toggle source

Returns the count and word where word is either singular or plural, depending on the count.

@example

pluralize(1, 'horse') # => "1 horse"
pluralize(2, 'cat') # => "2 cats"
# File lib/blur/text_helper.rb, line 15
def pluralize(count, word)
  "#{count} #{count == 1 ? word.singularize : word.pluralize}"
end
sanitize(string) click to toggle source

Sanitizes the string by removing carriage returns, newline feeds and redundant spaces.

@example

sanitize("the  quick brown  dog") # => "the quick brown dog"
# File lib/blur/text_helper.rb, line 24
def sanitize(string)
  string.gsub(/[\s]{2,}/, ' ').gsub(/[\r\n]/, ' ').strip
end