Class: SplitIoClient::EndsWithMatcher
- Inherits:
-
Object
- Object
- SplitIoClient::EndsWithMatcher
- Defined in:
- lib/splitclient-rb/engine/matchers/ends_with_matcher.rb
Constant Summary collapse
- MATCHER_TYPE =
'ENDS_WITH'
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
Instance Method Summary collapse
-
#initialize(attribute, suffix_list, logger) ⇒ EndsWithMatcher
constructor
A new instance of EndsWithMatcher.
- #match?(args) ⇒ Boolean
- #string_type? ⇒ Boolean
Constructor Details
#initialize(attribute, suffix_list, logger) ⇒ EndsWithMatcher
Returns a new instance of EndsWithMatcher.
9 10 11 12 13 |
# File 'lib/splitclient-rb/engine/matchers/ends_with_matcher.rb', line 9 def initialize(attribute, suffix_list, logger) @attribute = attribute @suffix_list = suffix_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/ends_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 27 28 |
# File 'lib/splitclient-rb/engine/matchers/ends_with_matcher.rb', line 15 def match?(args) value = get_value(args) @logger.log_if_debug("[EndsWithMatcher] Value from parameters: #{value}.") if @suffix_list.empty? @logger.log_if_debug('[EndsWithMatcher] Sufix List empty.') return false end matches = @suffix_list.any? { |suffix| value.to_s.end_with? suffix } @logger.log_if_debug("[EndsWithMatcher] #{value} ends with any #{@suffix_list}") matches end |
#string_type? ⇒ Boolean
30 31 32 |
# File 'lib/splitclient-rb/engine/matchers/ends_with_matcher.rb', line 30 def string_type? true end |