Sha256: a6e425dd03e4f66698db5aea116ee28605ad7223ac57e458f4e29030cd1227d4
Contents?: true
Size: 610 Bytes
Versions: 6
Compression:
Stored size: 610 Bytes
Contents
require 'dentaku/token' module Dentaku class TokenMatcher def initialize(categories=nil, values=nil) @categories = [categories].compact.flatten @values = [values].compact.flatten @invert = false end def invert @invert = ! @invert self end def ==(token) (category_match(token.category) && value_match(token.value)) ^ @invert end private def category_match(category) @categories.empty? || @categories.include?(category) end def value_match(value) @values.empty? || @values.include?(value) end end end
Version data entries
6 entries across 6 versions & 1 rubygems