Class: FlowEngine::Rules::GreaterThan
- Defined in:
- lib/flowengine/rules/greater_than.rb
Overview
Rule: the answer for the given field (coerced to integer) is greater than the threshold.
Instance Attribute Summary collapse
-
#field ⇒ Symbol
readonly
answer key.
-
#value ⇒ Integer
readonly
threshold.
Instance Method Summary collapse
-
#evaluate(answers) ⇒ Boolean
True if answers.to_i > value.
-
#initialize(field, value) ⇒ GreaterThan
constructor
A new instance of GreaterThan.
-
#to_s ⇒ String
E.g.
Constructor Details
#initialize(field, value) ⇒ GreaterThan
Returns a new instance of GreaterThan.
14 15 16 17 18 19 |
# File 'lib/flowengine/rules/greater_than.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/greater_than.rb', line 9 def field @field end |
#value ⇒ Integer (readonly)
threshold
9 10 11 |
# File 'lib/flowengine/rules/greater_than.rb', line 9 def value @value end |
Instance Method Details
#evaluate(answers) ⇒ Boolean
Returns true if answers.to_i > value.
23 24 25 |
# File 'lib/flowengine/rules/greater_than.rb', line 23 def evaluate(answers) answers[field].to_i > value end |
#to_s ⇒ String
Returns e.g. "business_income > 100000".
28 29 30 |
# File 'lib/flowengine/rules/greater_than.rb', line 28 def to_s "#{field} > #{value}" end |