Class: FeatureHub::Sdk::Impl::NumberMatcher
- Inherits:
-
StrategyMatcher
- Object
- StrategyMatcher
- FeatureHub::Sdk::Impl::NumberMatcher
- Defined in:
- lib/feature_hub/sdk/impl/strategy_wrappers.rb
Overview
matches floating point numbers excep for end/start/regexp
Instance Method Summary collapse
Instance Method Details
#match(supplied_value, attr) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/feature_hub/sdk/impl/strategy_wrappers.rb', line 66 def match(supplied_value, attr) cond = attr.conditional if cond.ends_with? attr.str_values.any? { |v| supplied_value.end_with?(v) } elsif cond.starts_with? attr.str_values.any? { |v| supplied_value.start_with?(v) } elsif cond.excludes? attr.str_values.none? { |v| supplied_value.include?(v) } elsif cond.includes? attr.str_values.any? { |v| supplied_value.include?(v) } elsif cond.regex? attr.str_values.any? { |v| !Regexp.new(v).match(supplied_value).nil? } else parsed_val = supplied_value.to_f vals = attr.float_values if cond.equals? vals.any? { |v| parsed_val == v } elsif cond.not_equals? vals.none? { |v| parsed_val == v } elsif cond.greater? vals.any? { |v| parsed_val > v } elsif cond.greater_equals? vals.any? { |v| parsed_val >= v } elsif cond.less? vals.any? { |v| parsed_val < v } elsif cond.less_equals? vals.any? { |v| parsed_val <= v } elsif cond.includes? vals.any? { |v| parsed_val.include?(v) } elsif cond.excludes? vals.none? { |v| parsed_val.include?(v) } else false end end end |