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
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/votd/helper/text.rb', line 28 def clean_verse_end(text) case text when /[a-zA-Z]$/ "#{text}..." when /[,;]$/ text.sub(/[,;]$/, "...") else text end end |
#clean_verse_start(text) ⇒ String
Prepends '...' if first letter is not a capital letter
21 22 23 |
# File 'lib/votd/helper/text.rb', line 21 def clean_verse_start(text) text.sub(/^([a-z])/, '...\1') end |
#strip_html_tags(text) ⇒ String
Removes HTML tags from the given text
14 15 16 |
# File 'lib/votd/helper/text.rb', line 14 def (text) text.gsub(/<\/?[^>]*>/, "") end |