Class: Factbase::ToString

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

Overview

This class is used to evaluate a term and return its string representation.

Instance Method Summary collapse

Methods included from TermShared

#to_s

Constructor Details

#initialize(operands) ⇒ ToString

Constructor.

Parameters:

  • operands (Array)

    Operands



12
13
14
15
# File 'lib/factbase/terms/to_string.rb', line 12

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

Instance Method Details

#evaluate(fact, maps, fb) ⇒ String

Evaluate term on a fact.

Parameters:

Returns:

  • (String)

    The same value as string



22
23
24
25
26
27
# File 'lib/factbase/terms/to_string.rb', line 22

def evaluate(fact, maps, fb)
  assert_args(1)
  vv = _values(0, fact, maps, fb)
  return nil if vv.nil?
  vv[0].to_s
end