Skip to content

Commit

Permalink
Add update method to BaseUpdater... one method to rule them all ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
francho committed Jun 10, 2016
1 parent 4355372 commit 3d80eb0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions gilded_rose.rb
Expand Up @@ -3,8 +3,7 @@
def update_quality(items)
items.each do |item|
updater = ItemUpdater.for item
updater.update_sell_in
updater.update_quality
updater.update
end
end

Expand Down
9 changes: 7 additions & 2 deletions lib/base_updater.rb
Expand Up @@ -3,6 +3,13 @@ def initialize(item)
@item = item
end

def update
update_sell_in
update_quality
end

protected

def update_quality
decrease_quality_by_one
decrease_quality_by_one if @item.sell_in < 0
Expand All @@ -12,8 +19,6 @@ def update_sell_in
@item.sell_in -= 1
end

protected

def decrease_quality_by_one
return unless @item.quality > 0
@item.quality -= 1
Expand Down

0 comments on commit 3d80eb0

Please sign in to comment.