Permalink
Browse files

Extract BackstageUpdater

  • Loading branch information...
francho committed Jun 10, 2016
1 parent 9d9e213 commit cbabdfcde8a93123da2eb05000b2c3e66c406253
Showing with 13 additions and 4 deletions.
  1. +10 −0 lib/backstage_updater.rb
  2. +3 −4 lib/item_updater.rb
View
@@ -0,0 +1,10 @@
require 'base_updater'
class BackstageUpdater < BaseUpdater
def update_quality
increase_quality_by_one
increase_quality_by_one if @item.sell_in < 10
increase_quality_by_one if @item.sell_in < 5
@item.quality = 0 if @item.sell_in < 0
end
end
View
@@ -1,5 +1,6 @@
require 'base_updater'
require 'aged_brie_updater'
require 'backstage_updater'
class ItemUpdater
def self.update(item)
@@ -9,10 +10,8 @@ def self.update(item)
def self.update_quality(item)
if backstage? item
increase_quality item
increase_quality item if item.sell_in < 10
increase_quality item if item.sell_in < 5
item.quality = 0 if item.sell_in < 0
updater = BackstageUpdater.new(item)
updater.update_quality
elsif aged_brie? item
updater = AgedBrieUpdater.new(item)
updater.update_quality

0 comments on commit cbabdfc

Please sign in to comment.