Class: SplitIoClient::LessThanOrEqualToMatcher
- Inherits:
-
Object
- Object
- SplitIoClient::LessThanOrEqualToMatcher
- Defined in:
- lib/splitclient-rb/engine/matchers/less_than_or_equal_to_matcher.rb
Constant Summary collapse
- MATCHER_TYPE =
'LESS_THAN_OR_EQUAL_TO'.freeze
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
Instance Method Summary collapse
- #equals?(obj) ⇒ Boolean
-
#initialize(attribute_hash) ⇒ LessThanOrEqualToMatcher
constructor
A new instance of LessThanOrEqualToMatcher.
- #match?(args) ⇒ Boolean
- #string_type? ⇒ Boolean
Constructor Details
#initialize(attribute_hash) ⇒ LessThanOrEqualToMatcher
Returns a new instance of LessThanOrEqualToMatcher.
7 8 9 10 11 |
# File 'lib/splitclient-rb/engine/matchers/less_than_or_equal_to_matcher.rb', line 7 def initialize(attribute_hash) @attribute = attribute_hash[:attribute] @data_type = attribute_hash[:data_type] @value = formatted_value(attribute_hash[:value], true) end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
5 6 7 |
# File 'lib/splitclient-rb/engine/matchers/less_than_or_equal_to_matcher.rb', line 5 def attribute @attribute end |
Instance Method Details
#equals?(obj) ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/splitclient-rb/engine/matchers/less_than_or_equal_to_matcher.rb', line 23 def equals?(obj) if obj.nil? false elsif !obj.instance_of?(LessThanOrEqualToMatcher) false elsif self.equal?(obj) true else false end end |
#match?(args) ⇒ Boolean
13 14 15 16 17 18 19 20 21 |
# File 'lib/splitclient-rb/engine/matchers/less_than_or_equal_to_matcher.rb', line 13 def match?(args) return false if !args.key?(:attributes) && !args.key?(:value) return false if args.key?(:value) && args[:value].nil? return false if args.key?(:attributes) && args[:attributes].nil? value = formatted_value(args[:value] || args[:attributes][@attribute.to_sym]) value.is_a?(Integer) ? (value <= @value) : false end |
#string_type? ⇒ Boolean
35 36 37 |
# File 'lib/splitclient-rb/engine/matchers/less_than_or_equal_to_matcher.rb', line 35 def string_type? false end |