Introduce ItemFactory in GildedRose::Store class

This commit is contained in:
Feken Baboyan 2021-03-03 22:14:32 -05:00
parent dc9e8be57d
commit f196a3ab9b

View File

@ -1,12 +1,12 @@
module GildedRose
class Store
def initialize(items)
@items = items
def initialize(raw_items)
@raw_items = raw_items
end
def update_quality()
@items.each do |item|
items.each do |item|
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert"
if item.quality > 0
if item.name != "Sulfuras, Hand of Ragnaros"
@ -52,6 +52,12 @@ module GildedRose
end
end
end
def items
@items ||= @raw_items.map do |item|
ItemFactory.create_item(name: item.name, sell_in: item.sell_in, quality: item.quality)
end
end
end
class Item