Class: FlowEngine::Rules::Equals
- Defined in:
- lib/flowengine/rules/equals.rb
Overview
Rule: the answer for the given field equals the given value.
Instance Attribute Summary collapse
-
#field ⇒ Symbol
readonly
answer key.
-
#value ⇒ Object
readonly
expected value.
Instance Method Summary collapse
-
#evaluate(answers) ⇒ Boolean
True if answers == value.
-
#initialize(field, value) ⇒ Equals
constructor
A new instance of Equals.
-
#to_s ⇒ String
E.g.
Constructor Details
#initialize(field, value) ⇒ Equals
Returns a new instance of Equals.
14 15 16 17 18 19 |
# File 'lib/flowengine/rules/equals.rb', line 14 def initialize(field, value) super() @field = field @value = value freeze end |
Instance Attribute Details
#field ⇒ Symbol (readonly)
answer key
9 10 11 |
# File 'lib/flowengine/rules/equals.rb', line 9 def field @field end |
#value ⇒ Object (readonly)
expected value
9 10 11 |
# File 'lib/flowengine/rules/equals.rb', line 9 def value @value end |
Instance Method Details
#evaluate(answers) ⇒ Boolean
Returns true if answers == value.
23 24 25 |
# File 'lib/flowengine/rules/equals.rb', line 23 def evaluate(answers) answers[field] == value end |
#to_s ⇒ String
Returns e.g. "marital_status == Married".
28 29 30 |
# File 'lib/flowengine/rules/equals.rb', line 28 def to_s "#{field} == #{value}" end |