mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-17 23:41:27 +00:00
variables updated
This commit is contained in:
parent
299a7efb12
commit
f5328837f8
@ -1,33 +1,36 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ItemProcessor
|
class ItemProcessor
|
||||||
attr_accessor :item
|
attr_accessor :item, :name, :sell_in, :quality
|
||||||
|
|
||||||
def initialize(item)
|
def initialize(item)
|
||||||
@item = item
|
@item = item
|
||||||
|
@quality = item.quality
|
||||||
|
@sell_in = item.sell_in
|
||||||
|
@name = item.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_item_quality
|
def update_item_quality
|
||||||
return if never_sold
|
return if never_sold
|
||||||
|
|
||||||
if (item.name != 'Aged Brie') && (item.name != 'Backstage passes to a TAFKAL80ETC concert')
|
if (name != 'Aged Brie') && (name != 'Backstage passes to a TAFKAL80ETC concert')
|
||||||
decrease_item_quality
|
decrease_item_quality
|
||||||
else
|
else
|
||||||
if item.quality < 50
|
if quality < 50
|
||||||
item.quality += 1
|
quality += 1
|
||||||
if item.name == 'Backstage passes to a TAFKAL80ETC concert'
|
if name == 'Backstage passes to a TAFKAL80ETC concert'
|
||||||
increase_item_quality if item.sell_in < 11
|
increase_item_quality if sell_in < 11
|
||||||
increase_item_quality if item.sell_in < 6
|
increase_item_quality if sell_in < 6
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
old_item
|
old_item
|
||||||
if item.sell_in < 0
|
if sell_in < 0
|
||||||
if item.name != 'Aged Brie'
|
if name != 'Aged Brie'
|
||||||
if item.name != 'Backstage passes to a TAFKAL80ETC concert'
|
if name != 'Backstage passes to a TAFKAL80ETC concert'
|
||||||
decrease_item_quality
|
decrease_item_quality
|
||||||
else
|
else
|
||||||
item.quality = item.quality - item.quality
|
quality -= quality
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
increase_item_quality
|
increase_item_quality
|
||||||
@ -36,18 +39,18 @@ class ItemProcessor
|
|||||||
end
|
end
|
||||||
|
|
||||||
def increase_item_quality
|
def increase_item_quality
|
||||||
item.quality += 1 if item.quality < 50
|
quality += 1 if quality < 50
|
||||||
end
|
end
|
||||||
|
|
||||||
def decrease_item_quality
|
def decrease_item_quality
|
||||||
item.quality -= 1 if item.quality > 0 && item.name != 'Sulfuras, Hand of Ragnaros'
|
quality -= 1 if item.quality > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def old_item
|
def old_item
|
||||||
item.sell_in = item.sell_in - 1 if item.name != 'Sulfuras, Hand of Ragnaros'
|
item.sell_in -= 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def never_sold
|
def never_sold
|
||||||
item.name == 'Sulfuras, Hand of Ragnaros'
|
name == 'Sulfuras, Hand of Ragnaros'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user