Sha256: 45e987cd7b9839d1a4d1bed1a16bf3d7021f13a64ea718d6a00d82c16be6a56a
Contents?: true
Size: 1.24 KB
Versions: 28
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module SplitIoClient class GreaterThanOrEqualToMatcher < Matcher MATCHER_TYPE = 'GREATER_THAN_OR_EQUAL_TO' attr_reader :attribute def initialize(attribute_hash) @attribute = attribute_hash[:attribute] @data_type = attribute_hash[:data_type] @value = formatted_value(attribute_hash[:value], true) end def match?(args) SplitLogger.log_if_debug('[GreaterThanOrEqualToMatcher] evaluating value and attributes.') return false unless SplitIoClient::Validators.valid_matcher_arguments(args) value = formatted_value(args[:value] || args[:attributes][@attribute.to_sym]) matches = value.is_a?(Integer) ? (value >= @value) : false SplitLogger.log_if_debug("[GreaterThanOrEqualToMatcher] #{value} greater than or equal to #{@value} -> #{matches}") matches end private def formatted_value(value, sdk_data = false) case @data_type when 'NUMBER' value when 'DATETIME' value /= 1000 if sdk_data # sdk returns already miliseconds, turning to seconds to do a correct zero_hour SplitIoClient::Utilities.to_milis_zero_out_from_seconds(value) else @logger.error('Invalid data type') end end end end
Version data entries
28 entries across 28 versions & 1 rubygems