Skip to content

Commit 993bcf3

Browse files
committed
Refactor: The calculate Instance Method Is No Longer Needed
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.
1 parent 7ab80e3 commit 993bcf3

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lib/ruby-progressbar/calculators/smoothed_average.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,18 @@ def progress
3333
samples[1]
3434
end
3535

36-
def progress=(new_progress)
37-
samples[1] = new_progress
38-
calculate(absolute)
39-
end
40-
4136
def total=(_new_total); end
4237

4338
def reset
4439
start(:at => samples[0])
4540
end
4641

47-
def calculate(new_value)
42+
def progress=(new_progress)
43+
samples[1] = new_progress
4844
self.projection = \
4945
self.class.calculate(
5046
@projection,
51-
new_value,
47+
absolute,
5248
strength
5349
)
5450
end

spec/lib/ruby-progressbar/calculators/smoothed_average_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Calculators
1919
it 'resets the projection' do
2020
projector = SmoothedAverage.new
2121
projector.start
22-
projector.calculate(10)
22+
projector.progress = 10
2323

2424
expect(projector.projection).not_to be_zero
2525

@@ -33,7 +33,7 @@ module Calculators
3333
it 'resets the projection' do
3434
projector = SmoothedAverage.new
3535
projector.start
36-
projector.calculate(10)
36+
projector.progress = 10
3737

3838
expect(projector.projection).not_to be_zero
3939

0 commit comments

Comments
 (0)