module Predicates
Private Instance Methods
equal_to?(that)
click to toggle source
# File lib/totally_lazy/predicates.rb, line 21 def equal_to?(that) predicate(->(this) { this == that }) end
Also aliased as: is
is_not(pred)
click to toggle source
# File lib/totally_lazy/predicates.rb, line 13 def is_not(pred) predicate(-> (bool) { !pred.(bool) }) end
matches(regex)
click to toggle source
# File lib/totally_lazy/predicates.rb, line 17 def matches(regex) predicate(->(value) { !regex.match(value).nil? }) end
predicate(fn)
click to toggle source
# File lib/totally_lazy/predicates.rb, line 3 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
where(fn, predicate)
click to toggle source
# File lib/totally_lazy/predicates.rb, line 26 def where(fn, predicate) predicate(->(value) { predicate.(fn.(value)) }) end