Skip to content

Commit

Permalink
Partial Backstage pass updater (tests are incomplete)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimweirich committed Feb 22, 2011
1 parent 932c368 commit e4c4e34
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions gilded_rose.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,34 @@ def bump(item, amount)
end
end

class BackstagePassQualityUpdater
def update_quality(item)
if item.sell_in > 10
bump(item, 1)
elsif item.sell_in > 5
bump(item, 2)
# elsif item.sell_in > 0
# bump(item, 3)
else
item.quality = 0
end
end
def update_sell_in(item)
item.sell_in -= 1
end
def bump(item, amount)
item.quality += amount
item.quality = 50 if item.quality >= 50
end
end

def update_one(item)
if item.name == 'Sulfuras, Hand of Ragnaros'
updater = NoopQualityUpdater.new
elsif item.name == 'Aged Brie'
updater = BrieQualityUpdater.new
elsif item.name == 'Backstage passes to a TAFKAL80ETC concert'
updater = BackstagePassQualityUpdater.new
else
updater = nil
end
Expand Down

0 comments on commit e4c4e34

Please sign in to comment.