Skip to content

Commit

Permalink
Refactor: The calculate Instance Method Is No Longer Needed
Browse files Browse the repository at this point in the history
Why This Change Is Necessary
========================================================================

This helper method is useless now.

What These Changes Do To Address the Issue
========================================================================

Inline the method.

Side Effects Caused By This Change
========================================================================

None expected.
  • Loading branch information
jfelchner committed Mar 4, 2023
1 parent 7ab80e3 commit 993bcf3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions lib/ruby-progressbar/calculators/smoothed_average.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,18 @@ def progress
samples[1]
end

def progress=(new_progress)
samples[1] = new_progress
calculate(absolute)
end

def total=(_new_total); end

def reset
start(:at => samples[0])
end

def calculate(new_value)
def progress=(new_progress)
samples[1] = new_progress
self.projection = \
self.class.calculate(
@projection,
new_value,
absolute,
strength
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Calculators
it 'resets the projection' do
projector = SmoothedAverage.new
projector.start
projector.calculate(10)
projector.progress = 10

expect(projector.projection).not_to be_zero

Expand All @@ -33,7 +33,7 @@ module Calculators
it 'resets the projection' do
projector = SmoothedAverage.new
projector.start
projector.calculate(10)
projector.progress = 10

expect(projector.projection).not_to be_zero

Expand Down

0 comments on commit 993bcf3

Please sign in to comment.