rootstrap/best_buy_ruby

View on GitHub
lib/best_buy/helpers/conditions/min_price_condition.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module BestBuy
  module Conditions
    class MinPriceCondition
      def initialize(condition_hash)
        @min_price = condition_hash[:min_price]
      end

      def valid?
        @min_price.present?
      end

      def search_query
        "((regularPrice>=#{@min_price}&onSale=false)|(salePrice>=#{@min_price}&onSale=true))"
      end
    end
  end
end