Class: SplitIoClient::EndsWithMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/splitclient-rb/engine/matchers/ends_with_matcher.rb

Constant Summary collapse

MATCHER_TYPE =
'ENDS_WITH'

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributeObject (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

Returns:

  • (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

Returns:

  • (Boolean)


30
31
32
# File 'lib/splitclient-rb/engine/matchers/ends_with_matcher.rb', line 30

def string_type?
  true
end