RSDComparableSurveyRule
public protocol RSDComparableSurveyRule : RSDComparable, RSDSurveyRule
RSDComparableSurveyRule
is a survey rule that matches an expected result to the answer and vends a skip
identifier if the match is evaluated to true
.
-
Optional skip identifier for this rule. If available, this will be used as the skip identifier, otherwise the
skipToIdentifier
will be assumed to beRSDIdentifier.exit
unless thecohort
is notnil
.Declaration
Swift
var skipToIdentifier: String? { get }
-
Optional cohort to assign if the rule matches. If non-nil, then the
evaluateRule()
function will return theskipToIdentifier
and will not assume exit if the skipToIdentifier isnil
.Declaration
Swift
var cohort: String? { get }
-
The rule operator to apply. If
nil
,.equal
will be assumed unless thematchingAnswer
is alsonil
, in which case.skip
will be assumed.Declaration
Swift
var ruleOperator: RSDSurveyRuleOperator? { get }
-
evaluateRule(with:)
Extension methodFor a given result (if any), what is the step that the survey should go to next?
For the
RSDComparableSurveyRule
, this will evaluate the result using theruleOperator
and thematchingAnswer
and return theskipIdentifier
if the rule evaluates totrue
.Declaration
Swift
public func evaluateRule(with result: RSDResult?) -> String?
Parameters
results
The result to evaluate.
Return Value
The identifier to skip to if the result evaluates to
true
. -
evaluateCohorts(with:)
Extension methodFor a given result (if any), what is the step that the survey should go to next?
For the
RSDComparableSurveyRule
, this will evaluate the result using theruleOperator
and thematchingAnswer
and return thecohort
to add if the rule evaluates totrue
or thecohort
to remove if the rule evaluates tofalse
.Declaration
Swift
public func evaluateCohorts(with result: RSDResult?) -> (add: Set<String>, remove: Set<String>)?
Parameters
results
The result to evaluate.
Return Value
The cohorts to add and remove.