Class: Factbase::Env
Overview
The ‘Factbase::Env` class is used to evaluate terms based on environment variables. It retrieves the value of an environment variable or returns a default value if the variable is not set.
Instance Method Summary collapse
-
#evaluate(fact, maps, fb) ⇒ String
Evaluate term on a fact.
-
#initialize(operands) ⇒ Env
constructor
Constructor.
Methods included from TermShared
Constructor Details
#initialize(operands) ⇒ Env
Constructor.
13 14 15 16 |
# File 'lib/factbase/terms/env.rb', line 13 def initialize(operands) super() @operands = operands end |
Instance Method Details
#evaluate(fact, maps, fb) ⇒ String
Evaluate term on a fact.
23 24 25 26 27 |
# File 'lib/factbase/terms/env.rb', line 23 def evaluate(fact, maps, fb) assert_args(2) n = _values(0, fact, maps, fb)[0] ENV.fetch(n.upcase) { _values(1, fact, maps, fb)[0] } end |