Sha256: df87003c6cb31ed0a1b58a1b79080b8c5fa8121735e8a93bc66b8c28fab494bf

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

module SplitIoClient

  class GreaterThanOrEqualToMatcher < NoMethodError

    attr_reader :matcher_type

    def initialize(attribute_hash)
      @matcher_type = "GREATER_THAN_OR_EQUAL_TO"
      @attribute = attribute_hash[:attribute]
      @value =  attribute_hash[:value]
      @data_type = attribute_hash[:data_type]
    end

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

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

    private
    def get_formatted_value(value)
      case @data_type
        when "NUMBER"
          return value
        when "DATETIME"
          return ::Utilities.to_milis_zero_out_from_seconds value
        else
          @logger.error('Invalid data type')
      end
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
splitclient-rb-1.0.3.wip1 lib/splitclient-engine/matchers/greater_than_or_equal_to_matcher.rb
splitclient-rb-1.0.2 lib/splitclient-engine/matchers/greater_than_or_equal_to_matcher.rb
splitclient-rb-1.0.2.wip2 lib/splitclient-engine/matchers/greater_than_or_equal_to_matcher.rb
splitclient-rb-1.0.2.wip lib/splitclient-engine/matchers/greater_than_or_equal_to_matcher.rb