Sha256: 3908f97ae01a87314d97abd518e7e8ed64f9032428f73b8ace3a280d116cdda8
Contents?: true
Size: 730 Bytes
Versions: 9
Compression:
Stored size: 730 Bytes
Contents
module Predicates private def predicate(fn) def fn.and(other) -> (value) { self.(value) && other.(value) } end def fn.or(other) -> (value) { self.(value) || other.(value) } end fn end def is_not(pred) predicate(-> (bool) { !pred.(bool) }) end def matches(regex) predicate(->(value) { !regex.match(value).nil? }) end def equal_to?(that) predicate(->(this) { this == that }) end alias is equal_to? def where(fn, predicate) predicate(->(value) { predicate.(fn.(value)) }) end end class PredicateFunction < Proc def and(other) ->(value) { self.(value) && other.(value) } end def or(other) ->(value) { self.(value) || other.(value) } end end
Version data entries
9 entries across 9 versions & 1 rubygems