mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-19 08:21:37 +00:00
18 lines
451 B
Ruby
18 lines
451 B
Ruby
module GildedRose
|
|
class ItemFactory
|
|
SPECIAL_ITEM_KLASSES = {
|
|
"Aged Brie" => AgedBrieItem,
|
|
"Backstage passes to a TAFKAL80ETC concert" => BackstagePassesItem,
|
|
"Sulfuras, Hand of Ragnaros" => SulfurasItem,
|
|
}
|
|
|
|
GENERIC_ITEM_KLASS = GenericItem
|
|
|
|
def self.create_item(name:, sell_in:, quality:)
|
|
klass = SPECIAL_ITEM_KLASSES.fetch(name, GENERIC_ITEM_KLASS)
|
|
klass.new(name, sell_in, quality)
|
|
end
|
|
end
|
|
end
|
|
|