Module: Blur::TextHelper
- Defined in:
- lib/blur/text_helper.rb,
lib/blur/text_helper/version.rb
Constant Summary collapse
- VERSION =
'0.1.0'.freeze
Instance Method Summary collapse
-
#pluralize(count, word) ⇒ Object
Returns the count and word where word is either singular or plural, depending on the count.
-
#sanitize(string) ⇒ Object
Sanitizes the string by removing carriage returns, newline feeds and redundant spaces.
Instance Method Details
#pluralize(count, word) ⇒ Object
Returns the count and word where word is either singular or plural, depending on the count.
15 16 17 |
# File 'lib/blur/text_helper.rb', line 15 def pluralize(count, word) "#{count} #{count == 1 ? word.singularize : word.pluralize}" end |
#sanitize(string) ⇒ Object
Sanitizes the string by removing carriage returns, newline feeds and redundant spaces.
24 25 26 |
# File 'lib/blur/text_helper.rb', line 24 def sanitize(string) string.gsub(/[\s]{2,}/, ' ').gsub(/[\r\n]/, ' ').strip end |