Class: Whos::Spam
- Inherits:
-
Object
- Object
- Whos::Spam
- Defined in:
- lib/whos/spam.rb
Instance Method Summary collapse
- #<<(s) ⇒ Object
- #filter(s) ⇒ Object
- #include?(s) ⇒ Boolean
-
#initialize ⇒ Spam
constructor
A new instance of Spam.
- #read(file) ⇒ Object
Constructor Details
#initialize ⇒ Spam
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.(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
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 |