module Votd::Helper::Text

This module contains helper methods that support the VotD text parsing.

Public Instance Methods

clean_verse_end(text) click to toggle source

Appends '…' if verse ends abruptly @param [String] text the text to process @return [String]

# File lib/votd/helper/text.rb, line 24
def clean_verse_end(text)
  case text
  when /[a-zA-Z]$/         # no ending "."
    text << '...'
  when /[,;]$/
    text.sub!(/[,;]$/, '...') # ends with "," or ";"
  else
    text
  end
  text
end
clean_verse_start(text) click to toggle source

Prepends '…' if first letter is not a capital letter @param [String] text the text to process @return [String]

# File lib/votd/helper/text.rb, line 17
def clean_verse_start(text)
  text.sub(/^([a-z])/, '...\1')
end
strip_html_tags(text) click to toggle source

Removes HTML tags from the given text @param [String] text the text you want to strip HTML tags from @return [String]

# File lib/votd/helper/text.rb, line 10
def strip_html_tags(text)
  text.gsub(/<\/?[^>]*>/, '')
end