Class: Logica::Predicates::PartialApplication

Inherits:
Base
  • Object
show all
Defined in:
lib/logica/predicates/partial_application.rb

Constant Summary

Constants inherited from Base

Base::ACCEPTOR_TYPE_ID

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#and, #and_not, #disjoint_with?, #exhaustive_with?, #generalization_of?, #generalization_of_negation_of?, #generalization_of_other?, #iff, #implies, #method_missing, #negated, #or, #or_not, #partially_applied_with, #portion_satisfied_by, predicate_factory, #remainder_unsatisfied_by, #respond_to_missing?, #specialization_of?, #to_method, #to_proc, #to_s, #unsatisfied_by?, #xor

Methods included from ComparableByState

#==, #hash, #state

Constructor Details

#initialize(predicate, first_arguments) ⇒ PartialApplication

Returns a new instance of PartialApplication.



6
7
8
9
# File 'lib/logica/predicates/partial_application.rb', line 6

def initialize(predicate, first_arguments)
  @predicate = predicate
  @first_arguments = first_arguments
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Logica::Predicates::Base

Instance Attribute Details

#first_argumentsObject (readonly)

Returns the value of attribute first_arguments.



4
5
6
# File 'lib/logica/predicates/partial_application.rb', line 4

def first_arguments
  @first_arguments
end

#predicateObject (readonly)

Returns the value of attribute predicate.



4
5
6
# File 'lib/logica/predicates/partial_application.rb', line 4

def predicate
  @predicate
end

Instance Method Details

#arityObject



15
16
17
# File 'lib/logica/predicates/partial_application.rb', line 15

def arity
  predicate.arity - first_arguments.size
end

#name_and_attributesObject



19
20
21
# File 'lib/logica/predicates/partial_application.rb', line 19

def name_and_attributes
  "#{predicate.name_and_attributes}(#{first_arguments.join(', ')})"
end

#satisfied_by?(*arguments) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/logica/predicates/partial_application.rb', line 11

def satisfied_by?(*arguments)
  predicate.satisfied_by?(*(first_arguments + arguments))
end