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
- #stem_verbs ⇒ Object
- #stemmed_verbs? ⇒ Boolean
- #strip_punctuation ⇒ Object
- #tag ⇒ Object
- #titlecase ⇒ Object
- #verb? ⇒ Boolean
Instance Method Details
#stem_verbs ⇒ Object
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
19 20 21 |
# File 'lib/style_scanner/string.rb', line 19 def stemmed_verbs? @stemmed_verbs end |
#strip_punctuation ⇒ Object
5 6 7 |
# File 'lib/style_scanner/string.rb', line 5 def strip_punctuation gsub(/[^a-zA-Z0-9\-\s]/, "").gsub(/\s{2,}/, " ") end |
#tag ⇒ Object
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 |
#titlecase ⇒ Object
15 16 17 |
# File 'lib/style_scanner/string.rb', line 15 def titlecase scan(/[A-Z][a-z]*/).join(" ") end |
#verb? ⇒ Boolean
23 24 25 |
# File 'lib/style_scanner/string.rb', line 23 def verb? tag.start_with?("V") end |