Class: Normalizator::EnumRule
- Defined in:
- lib/rules/enum_rule.rb
Constant Summary
Constants inherited from BaseRule
Instance Attribute Summary
Attributes inherited from BaseRule
Instance Method Summary collapse
Methods inherited from BaseRule
Constructor Details
This class inherits a constructor from Normalizator::BaseRule
Instance Method Details
#apply(value, _original_row) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rules/enum_rule.rb', line 4 def apply(value, _original_row) value_on_failure = get_value_on_failure(value) best_match = nil raise(RuleError, 'Array of enumerators is expected in the rule constructor options') unless @options[:enumerators].instance_of? Array @options[:enumerators].each do |enum| (best_match, perfect_match) = match_agains_enumerator(enum, value, best_match) break if perfect_match end best_match ? best_match : value_on_failure end |