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)


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

Parameters:

  • text (String)

    the text to process

Returns:

  • (String)


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

Parameters:

  • text (String)

    the text you want to strip HTML tags from

Returns:

  • (String)


14
15
16
# File 'lib/votd/helper/text.rb', line 14

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