mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-19 08:21:37 +00:00
19 lines
486 B
Ruby
19 lines
486 B
Ruby
module GildedRose
|
|
class ItemWrapperFactory
|
|
|
|
SPECIAL_ITEM_WRAPPER_KLASSES = {
|
|
"Aged Brie" => AgedBrieItemWrapper,
|
|
"Backstage passes to a TAFKAL80ETC concert" => BackstagePassesItemWrapper,
|
|
"Sulfuras, Hand of Ragnaros" => SulfurasItemWrapper,
|
|
}
|
|
|
|
GENERIC_ITEM_WRAPPER_KLASS = GenericItemWrapper
|
|
|
|
def self.wrap(item: )
|
|
klass = SPECIAL_ITEM_WRAPPER_KLASSES.fetch(item.name, GENERIC_ITEM_WRAPPER_KLASS)
|
|
klass.new(item: item)
|
|
end
|
|
end
|
|
end
|
|
|