Module: Votd::Helper::Text

Extended by:
Text
Included in:
Text
Defined in:
lib/votd/helper/text.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#clean_verse_end(text) ⇒ String

Appends ‘…’ if verse ends abruptly

Parameters:

  • text (String)

    the text to process

Returns:

  • (String)


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

Parameters:

  • text (String)

    the text to process

Returns:

  • (String)


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

Parameters:

  • text (String)

    the text you want to strip HTML tags from

Returns:

  • (String)


10
11
12
# File 'lib/votd/helper/text.rb', line 10

def strip_html_tags(text)
  text.gsub(/<\/?[^>]*>/, '')
end