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|
    word.verb? ? 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

#tagObject



27
28
29
30
31
# File 'lib/style_scanner/string.rb', line 27

def tag
  Tagger.new(self).tagged_words.find {|tagged_word| tagged_word.word == self }.tag
rescue NoMethodError
  "Unknown"
end

#titlecaseObject



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

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

#verb?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/style_scanner/string.rb', line 23

def verb?
  tag.start_with?("V")
end