File: ambiguous.rb

package info (click to toggle)
ruby-stamp 0.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 204 kB
  • sloc: ruby: 371; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 512 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module Stamp
  module Emitters
    class Ambiguous
      attr_reader :potential_emitters

      def initialize(*emitters)
        @potential_emitters = emitters
      end

      def field
        nil
      end

      def disambiguate(emitters)
        other_emitters = emitters - self
        known_fields = other_emitters.map { |e| e.field }.compact

        potential_emitters.reject do |potential_emitter|
          known_fields.include?(potential_emitter.field)
        end.first
      end
    end
  end
end