Class: Factbase::One

Inherits:
TermBase show all
Defined in:
lib/factbase/terms/one.rb

Overview

The term which property has exactly one value.

Author

Yegor Bugayenko ([email protected])

Copyright

Copyright © 2024-2025 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Methods included from TermShared

#to_s

Constructor Details

#initialize(operands) ⇒ One

Constructor.

Parameters:

  • operands (Array)

    Operands



15
16
17
18
# File 'lib/factbase/terms/one.rb', line 15

def initialize(operands)
  super()
  @operands = operands
end

Instance Method Details

#evaluate(fact, maps, fb) ⇒ Boolean

Evaluate term on a fact.

Parameters:

Returns:

  • (Boolean)

    True if exactly one value



25
26
27
28
29
# File 'lib/factbase/terms/one.rb', line 25

def evaluate(fact, maps, fb)
  assert_args(1)
  v = _values(0, fact, maps, fb)
  !v.nil? && v.size == 1
end