summaryrefslogtreecommitdiff
path: root/fake-service/lib/smail/search/and_match.rb
blob: 2bc53f0d8727ce8fe26b46ea742647f72b2cf0da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Smail
  class Search
    class AndMatch
      attr_reader :data
      def initialize(data = [])
        @data = data
      end
      def <<(node)
        @data << node
      end

      def to_s
        "And(#{@data.join(", ")})"
      end

      def match?(mail)
        self.data.all? { |mm| mm.match?(mail) }
      end

      def match_string?(str)
        self.data.all? { |mm| mm.match_string?(str) }
      end
    end
  end
end