Class: SplitIoClient::BetweenMatcher
- Defined in:
- lib/splitclient-rb/engine/matchers/between_matcher.rb
Constant Summary collapse
- MATCHER_TYPE =
'BETWEEN'
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
Instance Method Summary collapse
-
#initialize(attribute_hash, logger, validator) ⇒ BetweenMatcher
constructor
A new instance of BetweenMatcher.
- #match?(args) ⇒ Boolean
Methods inherited from Matcher
Constructor Details
#initialize(attribute_hash, logger, validator) ⇒ BetweenMatcher
Returns a new instance of BetweenMatcher.
9 10 11 12 13 14 15 16 |
# File 'lib/splitclient-rb/engine/matchers/between_matcher.rb', line 9 def initialize(attribute_hash, logger, validator) super(logger) @validator = validator @attribute = attribute_hash[:attribute] @data_type = attribute_hash[:data_type] @start_value = formatted_value(attribute_hash[:start_value], true) @end_value = formatted_value(attribute_hash[:end_value], true) end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
7 8 9 |
# File 'lib/splitclient-rb/engine/matchers/between_matcher.rb', line 7 def attribute @attribute end |
Instance Method Details
#match?(args) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/splitclient-rb/engine/matchers/between_matcher.rb', line 18 def match?(args) @logger.log_if_debug('[BetweenMatcher] evaluating value and attributes.') return false unless @validator.valid_matcher_arguments(args) value = formatted_value(args[:value] || args[:attributes][@attribute.to_sym]) @logger.log_if_debug("[BetweenMatcher] Value from parameters: #{value}.") return false unless value.is_a?(Integer) matches = (@start_value..@end_value).cover? value @logger.log_if_debug("[BetweenMatcher] is #{value} between #{@start_value} and #{@end_value} -> #{matches} .") matches end |