refactor v1

This commit is contained in:
lenise.rodrigues 2021-05-26 18:58:04 -03:00
parent a513926866
commit 10dc87ecc8
2 changed files with 30 additions and 38 deletions

2
ruby/.bundle/config Normal file
View File

@ -0,0 +1,2 @@
---
BUNDLE_BIN: "bin"

View File

@ -6,50 +6,40 @@ class GildedRose
def update_quality() 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" case item.name
if item.quality > 0 when "Sulfuras, Hand of Ragnaros"
if item.name != "Sulfuras, Hand of Ragnaros" when "Backstage passes to a TAFKAL80ETC concert"
item.quality = item.quality - 1 item.quality += 1 if item.sell_in > 10
item.quality += 2 if item.sell_in <= 10 and item.sell_in > 5
item.quality += 3 if item.sell_in <= 5
item.sell_in -= 1
item.quality = 0 if item.sell_in < 0
when "Aged Brie"
item.sell_in -= 1
if item.quality < 50
if item.sell_in < 0
item.quality += 2
else
item.quality += 1
end end
end end
when /Conjured/
item.sell_in -= 1
if item.quality > 0
item.quality -= 2
item.quality -= 2 if item.sell_in < 0
end
else else
if item.quality < 50 item.sell_in -= 1
item.quality = item.quality + 1 if item.quality > 0
if item.name == "Backstage passes to a TAFKAL80ETC concert" item.quality -= 1
if item.sell_in < 11 item.quality -= 1 if item.sell_in < 0
if item.quality < 50
item.quality = item.quality + 1
end
end
if item.sell_in < 6
if item.quality < 50
item.quality = item.quality + 1
end
end
end
end end
end end
if item.name != "Sulfuras, Hand of Ragnaros" if item.quality < 0
item.sell_in = item.sell_in - 1 item.quality = 0
end end
if item.sell_in < 0 end
if item.name != "Aged Brie"
if item.name != "Backstage passes to a TAFKAL80ETC concert"
if item.quality > 0
if item.name != "Sulfuras, Hand of Ragnaros"
item.quality = item.quality - 1
end
end
else
item.quality = item.quality - item.quality
end
else
if item.quality < 50
item.quality = item.quality + 1
end
end
end
end
end end
end end