Class: SplitIoClient::StartsWithMatcher
- Inherits:
-
Object
- Object
- SplitIoClient::StartsWithMatcher
- Defined in:
- lib/splitclient-rb/engine/matchers/starts_with_matcher.rb
Constant Summary collapse
- MATCHER_TYPE =
'STARTS_WITH'
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
Instance Method Summary collapse
-
#initialize(attribute, prefix_list, logger) ⇒ StartsWithMatcher
constructor
A new instance of StartsWithMatcher.
- #match?(args) ⇒ Boolean
- #string_type? ⇒ Boolean
Constructor Details
#initialize(attribute, prefix_list, logger) ⇒ StartsWithMatcher
Returns a new instance of StartsWithMatcher.
9 10 11 12 13 |
# File 'lib/splitclient-rb/engine/matchers/starts_with_matcher.rb', line 9 def initialize(attribute, prefix_list, logger) @attribute = attribute @prefix_list = prefix_list @logger = logger end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
7 8 9 |
# File 'lib/splitclient-rb/engine/matchers/starts_with_matcher.rb', line 7 def attribute @attribute end |
Instance Method Details
#match?(args) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/splitclient-rb/engine/matchers/starts_with_matcher.rb', line 15 def match?(args) if @prefix_list.empty? @logger.log_if_debug('[StartsWithMatcher] Prefix List is empty.') return false end value = get_value(args) matches = @prefix_list.any? { |prefix| value.to_s.start_with? prefix } @logger.log_if_debug("[StartsWithMatcher] #{value} matches any of #{@prefix_list} -> #{matches}") matches end |
#string_type? ⇒ Boolean
28 29 30 |
# File 'lib/splitclient-rb/engine/matchers/starts_with_matcher.rb', line 28 def string_type? true end |