<commit_before>
#require_relative "lib/errors"
class Product
	@@products = []
	@@product_in_stock = []
	attr_accessor :title, :price, :stock
	
	def initialize(string = {})
		@title = string[:title] 
		@price = string[:price] 
		@stock = string[:stock] 
		add_to_products
	end	
	def self.all
		@@products
	end

	def self.find_by_title(string)
		@@products.each do |i|
			if(i.title == string)
			return i
			end
		end
	end	

	def in_stock?
		if @stock > 0
			return true
		else
			return false
		end
	end

	def self.in_stock
	
		@@products.each do |i|
			if(i.stock > 0)
				@@product_in_stock.push(i)
			end
		end
		return @@product_in_stock
	end




	private
	def add_to_products
		@@products.each do |i|
			if(i.title == @title)
			raise DuplicateProductError, "'#{@title}' already exists"
			end
		end	
			@@products << self
	end		



end<commit_msg>added new features<commit_after>
#require_relative "lib/errors"
class Product
	@@products = []
	@@product_in_stock = []
	attr_accessor :title, :price, :stock
	
	def initialize(string = {})
		@title = string[:title] 
		@price = string[:price] 
		@stock = string[:stock] 
		add_to_products
	end	
	def self.all
		@@products
	end

	def self.find_by_title(string)
		@@products.each do |i|
			if(i.title == string)
			return i
			end
		end
	end	

	def in_stock?
		if @stock > 0
			return true
		else
			return false
		end
	end

	def self.in_stock
	
		@@products.each do |i|
			if(i.stock > 0)
				@@product_in_stock.push(i)
			end
		end
		@@product_in_stock
	end

	def self.out_stock
		@@products.each do |i|
			if(i.stock == 0)
				puts "The below items are out of stock, please consider replenishing"
				puts "#{i.title}"
			end
		end
		
	end

	def self.low_stock
		@@products.each do |i|
			if(i.stock >0 && i.stock < 5)
				puts "The below items are low on stock, please consider replenishing"
				puts "#{i.title}"
			end
		end
		
	end




	private
	def add_to_products
		@@products.each do |i|
			if(i.title == @title)
			raise DuplicateProductError, "'#{@title}' already exists"
			end
		end	
			@@products << self
	end		



end
{'fraction_non_alphanumeric': 0.1185789726356217, 'fraction_numerical': 0.003360537686029765, 'mean_word_length': 2.9320754716981132, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1946488', 'n_tokens_mistral': 923, 'n_tokens_neox': 775, 'n_words': 210}