class Logica::PredicateFactory

Public Instance Methods

ad_hoc(name = 'anonymous', &definition) click to toggle source
# File lib/logica/predicate_factory.rb, line 60
def ad_hoc(name = 'anonymous', &definition)
  ad_hoc_class.new(name, &definition)
end
Also aliased as: from_block
at_least(minimum, predicates) click to toggle source
# File lib/logica/predicate_factory.rb, line 23
def at_least(minimum, predicates)
  if minimum <= 0
    tautology
  elsif minimum == 1
    disjunction(predicates)
  elsif minimum == predicates.size
    conjunction(predicates)
  elsif minimum >= predicates.size
    contradiction
  else
    at_least_class.new(minimum, predicates)
  end
end
at_most(maximum, predicates) click to toggle source
# File lib/logica/predicate_factory.rb, line 37
def at_most(maximum, predicates)
  minimum   = predicates.size - maximum
  negations = predicates.map(&:negated)

  at_least(minimum, negations)
end
between(minimum, maximum, predicates) click to toggle source
# File lib/logica/predicate_factory.rb, line 44
def between(minimum, maximum, predicates)
  at_least(minimum, predicates).and(at_most(maximum, predicates))
end
conjunction(predicates) click to toggle source
# File lib/logica/predicate_factory.rb, line 3
def conjunction(predicates)
  compound_from_list(predicates, conjunction_class)
end
conjunction_from_pair(first_predicate, second_predicate) click to toggle source
# File lib/logica/predicate_factory.rb, line 7
def conjunction_from_pair(first_predicate, second_predicate)
  compound_from_pair(first_predicate, second_predicate, conjunction_class)
end
contradiction() click to toggle source
# File lib/logica/predicate_factory.rb, line 56
def contradiction
  contradiction_class.new
end
disjunction(predicates) click to toggle source
# File lib/logica/predicate_factory.rb, line 11
def disjunction(predicates)
  compound_from_list(predicates, disjunction_class)
end
disjunction_from_pair(first_predicate, second_predicate) click to toggle source
# File lib/logica/predicate_factory.rb, line 15
def disjunction_from_pair(first_predicate, second_predicate)
  compound_from_pair(first_predicate, second_predicate, disjunction_class)
end
exactly(amount, predicates) click to toggle source
# File lib/logica/predicate_factory.rb, line 48
def exactly(amount, predicates)
  between(amount, amount, predicates)
end
from_block(name = 'anonymous', &definition)
Alias for: ad_hoc
negation(predicate) click to toggle source
# File lib/logica/predicate_factory.rb, line 19
def negation(predicate)
  negation_class.new(predicate)
end
partial_application(predicate, *first_arguments) click to toggle source
# File lib/logica/predicate_factory.rb, line 65
def partial_application(predicate, *first_arguments)
  partial_application_class.new(predicate, *first_arguments)
end
tautology() click to toggle source
# File lib/logica/predicate_factory.rb, line 52
def tautology
  tautology_class.new
end

Private Instance Methods

ad_hoc_class() click to toggle source
# File lib/logica/predicate_factory.rb, line 103
def ad_hoc_class
  Predicates::AdHoc
end
at_least_class() click to toggle source
# File lib/logica/predicate_factory.rb, line 91
def at_least_class
  Predicates::Compounds::AtLeast
end
compound_from_list(predicates, compound_class) click to toggle source
# File lib/logica/predicate_factory.rb, line 71
def compound_from_list(predicates, compound_class)
  compound_class.new_from_list(predicates)
end
compound_from_pair(first_predicate, second_predicate, compound_class) click to toggle source
# File lib/logica/predicate_factory.rb, line 75
def compound_from_pair(first_predicate, second_predicate, compound_class)
  compound_class.new_from_pair(first_predicate, second_predicate)
end
conjunction_class() click to toggle source
# File lib/logica/predicate_factory.rb, line 83
def conjunction_class
  Predicates::Compounds::Conjunction
end
contradiction_class() click to toggle source
# File lib/logica/predicate_factory.rb, line 99
def contradiction_class
  Predicates::Contradiction
end
disjunction_class() click to toggle source
# File lib/logica/predicate_factory.rb, line 87
def disjunction_class
  Predicates::Compounds::Disjunction
end
negation_class() click to toggle source
# File lib/logica/predicate_factory.rb, line 79
def negation_class
  Predicates::Negation
end
partial_application_class() click to toggle source
# File lib/logica/predicate_factory.rb, line 107
def partial_application_class
  Predicates::PartialApplication
end
tautology_class() click to toggle source
# File lib/logica/predicate_factory.rb, line 95
def tautology_class
  Predicates::Tautology
end