mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 04:12:13 +00:00
Style fix: ruby always uses 2-space indentation
This commit is contained in:
parent
9042bba0a2
commit
7541689452
@ -1,67 +1,65 @@
|
|||||||
|
|
||||||
class GildedRose
|
class GildedRose
|
||||||
def update_quality(items)
|
def update_quality(items)
|
||||||
items.each do |item|
|
items.each do |item|
|
||||||
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert"
|
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert"
|
||||||
if item.quality > 0
|
if item.quality > 0
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros"
|
if item.name != "Sulfuras, Hand of Ragnaros"
|
||||||
item.quality = item.quality - 1
|
item.quality = item.quality - 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
else
|
|
||||||
if item.quality < 50
|
|
||||||
item.quality = item.quality + 1
|
|
||||||
if item.name == "Backstage passes to a TAFKAL80ETC concert"
|
|
||||||
if item.sell_in < 11
|
|
||||||
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
|
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros"
|
|
||||||
item.sell_in = item.sell_in - 1
|
|
||||||
end
|
|
||||||
if item.sell_in < 0
|
|
||||||
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
|
||||||
items
|
else
|
||||||
|
if item.quality < 50
|
||||||
|
item.quality = item.quality + 1
|
||||||
|
if item.name == "Backstage passes to a TAFKAL80ETC concert"
|
||||||
|
if item.sell_in < 11
|
||||||
|
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
|
||||||
|
if item.name != "Sulfuras, Hand of Ragnaros"
|
||||||
|
item.sell_in = item.sell_in - 1
|
||||||
|
end
|
||||||
|
if item.sell_in < 0
|
||||||
|
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
|
||||||
|
items
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Item
|
class Item
|
||||||
attr_accessor :name, :sell_in, :quality
|
attr_accessor :name, :sell_in, :quality
|
||||||
|
|
||||||
def initialize(name, sell_in, quality)
|
|
||||||
@name = name
|
|
||||||
@sell_in = sell_in
|
|
||||||
@quality = quality
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s()
|
|
||||||
"#{@name}, #{@sell_in}, #{@quality}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
def initialize(name, sell_in, quality)
|
||||||
|
@name = name
|
||||||
|
@sell_in = sell_in
|
||||||
|
@quality = quality
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s()
|
||||||
|
"#{@name}, #{@sell_in}, #{@quality}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user