Class: Whos::Spam

Inherits:
Object
  • Object
show all
Defined in:
lib/whos/spam.rb

Instance Method Summary collapse

Constructor Details

#initializeSpam

Returns a new instance of Spam.



3
4
5
6
7
8
9
10
# File 'lib/whos/spam.rb', line 3

def initialize
  @lines = []
  here = File.expand_path(File.dirname(__FILE__))      
  spam_dir = "#{here}/../../spam"
  Dir.glob("#{spam_dir}/*").each do |file|
    read file
  end
end

Instance Method Details

#<<(s) ⇒ Object



12
13
14
# File 'lib/whos/spam.rb', line 12

def << s
  @lines << s.strip
end

#filter(s) ⇒ Object



27
28
29
30
31
# File 'lib/whos/spam.rb', line 27

def filter s
  s.each_line.reject do |line|
    include? line
  end.join("\n")
end

#include?(s) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/whos/spam.rb', line 22

def include? s
  s.strip!
  s == "" or @lines.include? s
end

#read(file) ⇒ Object



16
17
18
19
20
# File 'lib/whos/spam.rb', line 16

def read file
  File.read(file).each_line do |line|
    self << line
  end
end