Sha256: 22b0a9843a281c2431870483e284f89679270067e6be6383cd27ce9fb7243079
Contents?: true
Size: 1.45 KB
Versions: 3
Compression:
Stored size: 1.45 KB
Contents
module Veritas module Logic class Predicate # A mixin for predicates with directly compared operands module Comparable include Immutable # Hook called when module is included # # @param [Module] descendant # the module or class including Comparable # # @return [self] # # @api private def self.included(descendant) descendant.extend ClassMethods self end # Return a string representing the predicate # # @example # predicate.inspect # (String representation of Predicate) # # @return [String] # # @api public def inspect "#{left.inspect} #{self.class.operation} #{right.inspect}" end module ClassMethods # Evaluate the values using the ruby operation # # @example # predicate.call(left, right) # => true or false # # @param [Object] left # @param [Object] right # # @return [Boolean] # # @api public def call(left, right) # methods ending in ? should return true or false only, # force boolean context using !! !!left.send(operation, right) end end # module Classmethods end # module Comparable end # class Predicate end # module Logic end # module Veritas
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
veritas-0.0.3 | lib/veritas/logic/predicate/comparable.rb |
veritas-0.0.2 | lib/veritas/logic/predicate/comparable.rb |
veritas-0.0.1 | lib/veritas/logic/predicate/comparable.rb |