Class: Rundown::Processors::Email

Inherits:
Rundown::Processor show all
Defined in:
lib/rundown/processors/email.rb

Constant Summary collapse

REGEX =
/\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/

Constants inherited from Rundown::Processor

Rundown::Processor::PUNCTUATION

Instance Attribute Summary

Attributes inherited from Rundown::Processor

#text, #words

Instance Method Summary collapse

Methods inherited from Rundown::Processor

#initialize, #sentences

Constructor Details

This class inherits a constructor from Rundown::Processor

Instance Method Details

#cleanup_wordsObject



6
7
8
9
10
# File 'lib/rundown/processors/email.rb', line 6

def cleanup_words
  words = @words.map { |word|
    word.gsub!(/\(|\)/, "")
  }
end

#processObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rundown/processors/email.rb', line 12

def process
  cleanup_words
  words.select { |word|
    Array(word.match(REGEX))[0]
  }.reject(&:empty?).map {|word|
    word.split('@')
  }.reject { |words|
    words.size < 2 
  }.select { |words|
    x = Array(words.last).last.to_s.split('.').last
    x.length <= 4 && !x.match(/\d+/)
  }.map { |words|
    words.join("@")
  }
end