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) ⇒ EndsWithMatcher

Returns a new instance of EndsWithMatcher.



9
10
11
12
# File 'lib/splitclient-rb/engine/matchers/ends_with_matcher.rb', line 9

def initialize(attribute, suffix_list)
  @attribute = attribute
  @suffix_list = suffix_list
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

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/splitclient-rb/engine/matchers/ends_with_matcher.rb', line 14

def match?(args)
  value = get_value(args)

  SplitLogger.log_if_debug("[EndsWithMatcher] Value from parameters: #{value}.")

  if @suffix_list.empty?
    SplitLogger.log_if_debug('[EndsWithMatcher] Sufix List empty.')
    return false
  end

  matches = @suffix_list.any? { |suffix| value.to_s.end_with? suffix }
  SplitLogger.log_if_debug("[EndsWithMatcher] #{value} ends with any #{@suffix_list}")
  matches
end

#string_type? ⇒ Boolean

Returns:

  • (Boolean)


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

def string_type?
  true
end