Sha256: 504669fd24f76b5aff071c6ed66ebd69488567af84bf1803316a64132911f08d
Contents?: true
Size: 614 Bytes
Versions: 5
Compression:
Stored size: 614 Bytes
Contents
require_relative 'tags' module Signore class SigFinder def self.find(sigs, random: Random.new, tags: Tags.new) new(sigs, random: random).find_tagged(tags: tags) end def initialize(sigs, random: Random.new) @random = random @sigs = sigs end def find_tagged(tags: Tags.new) sigs .select { |sig| tags.required.all? { |tag| sig.tagged_with?(tag) } } .reject { |sig| tags.forbidden.any? { |tag| sig.tagged_with?(tag) } } .sample(random: random) or Signature.new end attr_reader :random, :sigs private :random, :sigs end end
Version data entries
5 entries across 5 versions & 1 rubygems