Sha256: f89fb41eeaba3b49ac0e659531805b948d31171fa3e0ec2f3293aa0fa36396cf
Contents?: true
Size: 694 Bytes
Versions: 7
Compression:
Stored size: 694 Bytes
Contents
module WarningSigns class RubyCategoryMatcher attr_accessor :only, :except def initialize(only: [], except: []) @only = only.compact.map { _1.to_sym } @except = except.compact.map { _1.to_sym } end def match?(category) category = :blank if category.blank? only_match?(category) && except_match?(category) end def only_match?(category) return true if only.empty? only.any? do |only_pattern| only_pattern === category&.to_sym end end def except_match?(category) return true if except.empty? except.none? do |except_pattern| except_pattern === category&.to_sym end end end end
Version data entries
7 entries across 7 versions & 1 rubygems