Module: MetadataPresenter::WordCount

Included in:
MaxWordValidator, MinWordValidator
Defined in:
app/validators/metadata_presenter/word_count.rb

Instance Method Summary collapse

Instance Method Details

#strip_punctuation(text) ⇒ Object



11
12
13
# File 'app/validators/metadata_presenter/word_count.rb', line 11

def strip_punctuation(text)
  text.gsub(/[^a-z0-9\s]/i, '')
end

#strip_tags(text) ⇒ Object



7
8
9
# File 'app/validators/metadata_presenter/word_count.rb', line 7

def strip_tags(text)
  strip_punctuation(ActionController::Base.helpers.strip_tags(text))
end

#word_count(text) ⇒ Object



3
4
5
# File 'app/validators/metadata_presenter/word_count.rb', line 3

def word_count(text)
  strip_tags(text).split.size
end