diff --git a/lib/sof/cycles/within.rb b/lib/sof/cycles/within.rb index bcc06e9..2c1aa85 100644 --- a/lib/sof/cycles/within.rb +++ b/lib/sof/cycles/within.rb @@ -12,6 +12,13 @@ def self.recurring? = false def to_s = "#{volume}x within #{date_range}" + def notation_extended_by(count) + Parser.load( + parser.to_h.merge(period_count: period_count + count) + ).to_s + end + alias_method :grant_extension, :notation_extended_by + def date_range return humanized_span unless active? diff --git a/spec/sof/cycles/within_spec.rb b/spec/sof/cycles/within_spec.rb index d2865da..4838b60 100644 --- a/spec/sof/cycles/within_spec.rb +++ b/spec/sof/cycles/within_spec.rb @@ -34,6 +34,17 @@ module SOF given: "_", returns: ("2020-08-01".to_date + 180.days) it_behaves_like "last_completed is", :too_late + describe "#notation_extended_by" do + it "increases the period by the given amount" do + aggregate_failures do + expect(cycle.notation).to eq("V2W180DF2020-08-01") + + notation = cycle.notation_extended_by(30) + expect(notation).to eq("V2W210DF2020-08-01") + end + end + end + describe "#recurring?" do it "does not repeat" do expect(cycle).not_to be_recurring