Sha256: 5270154717dbdeeb52cbf42db1bd0b64e713b809537bcec42d1334cc4bb33246
Contents?: true
Size: 1.23 KB
Versions: 28
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module SplitIoClient class LessThanOrEqualToMatcher < Matcher MATCHER_TYPE = 'LESS_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('[LessThanOrEqualToMatcher] 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("[LessThanOrEqualToMatcher] #{value} less 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