Module: Votd::Helper::Text
Overview
This module contains helper methods that support the VotD text parsing.
Instance Method Summary collapse
-
#clean_verse_end(text) ⇒ String
Appends ‘…’ if verse ends abruptly.
-
#clean_verse_start(text) ⇒ String
Prepends ‘…’ if first letter is not a capital letter.
-
#strip_html_tags(text) ⇒ String
Removes HTML tags from the given text.
Instance Method Details
#clean_verse_end(text) ⇒ String
Appends ‘…’ if verse ends abruptly
24 25 26 27 28 29 30 31 32 33 34 |
# 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) ⇒ String
Prepends ‘…’ if first letter is not a capital letter
17 18 19 |
# File 'lib/votd/helper/text.rb', line 17 def clean_verse_start(text) text.sub(/^([a-z])/, '...\1') end |
#strip_html_tags(text) ⇒ String
Removes HTML tags from the given text
10 11 12 |
# File 'lib/votd/helper/text.rb', line 10 def (text) text.gsub(/<\/?[^>]*>/, '') end |