Class: Kafo::Condition
- Inherits:
-
Object
- Object
- Kafo::Condition
- Defined in:
- lib/kafo/condition.rb
Constant Summary collapse
- VARIABLE_RE =
/(\$\w+)/
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(expression, context = []) ⇒ Condition
constructor
A new instance of Condition.
Constructor Details
#initialize(expression, context = []) ⇒ Condition
Returns a new instance of Condition.
6 7 8 9 |
# File 'lib/kafo/condition.rb', line 6 def initialize(expression, context = []) @expression = expression @context = context end |
Instance Method Details
#evaluate ⇒ Object
11 12 13 |
# File 'lib/kafo/condition.rb', line 11 def evaluate !!eval(substitute(@expression)) end |