Module: StyleScanner::StringExtensions

Defined in:
lib/style_scanner/string.rb

Overview

Module is used to help people trace where the monkey patched methods came from olabini.com/blog/2011/01/safeer-monkey-patching/

Instance Method Summary collapse

Instance Method Details

#stem_verbsObject



9
10
11
12
13
# File 'lib/style_scanner/string.rb', line 9

def stem_verbs
  strip_punctuation.split.map do |word|
    is_a_verb?(word) ? word.stem : word
  end.join(" ")
end

#stemmed_verbs?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/style_scanner/string.rb', line 19

def stemmed_verbs?
  @stemmed_verbs
end

#strip_punctuationObject



5
6
7
# File 'lib/style_scanner/string.rb', line 5

def strip_punctuation
  gsub(/[^a-zA-Z0-9\-\s]/, "").gsub(/\s{2,}/, " ")
end

#titlecaseObject



15
16
17
# File 'lib/style_scanner/string.rb', line 15

def titlecase
  scan(/[A-Z][a-z]*/).join(" ") 
end