Exception: SplitIoClient::LessThanOrEqualToMatcher

Inherits:
NoMethodError
  • Object
show all
Defined in:
lib/engine/matchers/less_than_or_equal_to_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute_hash) ⇒ LessThanOrEqualToMatcher

Returns a new instance of LessThanOrEqualToMatcher.



7
8
9
10
11
12
# File 'lib/engine/matchers/less_than_or_equal_to_matcher.rb', line 7

def initialize(attribute_hash)
  @matcher_type = "LESS_THAN_OR_EQUAL_TO"
  @attribute = attribute_hash[:attribute]
  @data_type = attribute_hash[:data_type]
  @value = get_formatted_value attribute_hash[:value], true
end

Instance Attribute Details

#matcher_typeObject (readonly)

Returns the value of attribute matcher_type.



5
6
7
# File 'lib/engine/matchers/less_than_or_equal_to_matcher.rb', line 5

def matcher_type
  @matcher_type
end

Instance Method Details

#equals?(obj) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/engine/matchers/less_than_or_equal_to_matcher.rb', line 22

def equals?(obj)
  if obj.nil?
    false
  elsif !obj.instance_of?(LessThanOrEqualToMatcher)
    false
  elsif self.equal?(obj)
    true
  else
    false
  end
end

#match?(key, attributes) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
# File 'lib/engine/matchers/less_than_or_equal_to_matcher.rb', line 14

def match?(key, attributes)
  matches = false
  if (!attributes.nil? && attributes.key?(@attribute.to_sym))
    param_value = get_formatted_value(attributes[@attribute.to_sym])
    matches = param_value.is_a?(Integer) ? (param_value <= @value) : false
  end
end