rootstrap/best_buy_ruby

View on GitHub
lib/best_buy/search_query_builder.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module BestBuy
  class SearchQueryBuilder
    def add(condition)
      conditions << condition
    end

    def build
      return '' unless conditions.any?

      "(#{conditions.join('&')})"
    end

    private

    def conditions
      @conditions ||= []
    end
  end
end