rootstrap/best_buy_ruby

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

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module BestBuy
  module Conditions
    class MaxPriceCondition
      def initialize(condition_hash)
        @max_price = condition_hash[:max_price]
      end

      def valid?
        @max_price.present?
      end

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