Class: Tensai::Logic::Predicate

Inherits:
Object
  • Object
show all
Defined in:
lib/tensai/logic/predicate.rb

Overview

Predicate

Instance Method Summary collapse

Instance Method Details

#accepts?(values) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/tensai/logic/predicate.rb', line 25

def accepts?(values)
  Set.new(values.keys) == variable_names &&
    variables.all? { |v| v.accepts? values[v.name] }
end

#after_initializeObject

Raises:

  • (ArgumentError)


21
22
23
# File 'lib/tensai/logic/predicate.rb', line 21

def after_initialize
  raise ArgumentError, 'All variable names must be unique' if variable_names.size < variables.size
end

#inspectObject



30
31
32
# File 'lib/tensai/logic/predicate.rb', line 30

def inspect
  "(#{name} #{variables.map(&:inspect).join(' ')})"
end