From 56370b0f89f9f5e1bbe30c8475e6d40e48e0cc34 Mon Sep 17 00:00:00 2001 From: davidraj Date: Mon, 10 Oct 2022 16:57:36 +0100 Subject: [PATCH] composing into smaller methods --- ruby/item_processor.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ruby/item_processor.rb b/ruby/item_processor.rb index c26626e0..a9fc3987 100644 --- a/ruby/item_processor.rb +++ b/ruby/item_processor.rb @@ -16,12 +16,8 @@ class ItemProcessor if item.quality < 50 item.quality += 1 if item.name == 'Backstage passes to a TAFKAL80ETC concert' - if item.sell_in < 11 - item.quality += 1 if item.quality < 50 - end - if item.sell_in < 6 - item.quality += 1 if item.quality < 50 - end + increase_item_quality if item.sell_in < 11 + increase_item_quality if item.sell_in < 6 end end end @@ -36,8 +32,12 @@ class ItemProcessor item.quality = item.quality - item.quality end else - item.quality += 1 if item.quality < 50 + increase_item_quality end end end + + def increase_item_quality + item.quality += 1 if item.quality < 50 + end end