Commit 7ab80e3
committed
Refactor: Projector To Be Able To Keep Track Of Progress
Why This Change Is Necessary
========================================================================
Previously we were passing new values into `calculate` but were not
saving them.
In order to be able to be more useful in more situations, we need to
have the projector be called each time progress is updated and be able
to save that data if necessary for future projections.
This particular calculator only needs two values (the starting point and
the current point) but other projectors may need more (for example
a projector that only cares about the last n minutes of items or one
that only cares about the last x items).
What These Changes Do To Address the Issue
========================================================================
Because the projector is now tied into progress events, all we have to
do is implement those methods and save the data as necessary.
We introduce a concept of "samples" into the projector. Each projector
will be responsible for holding as many samples of progress data as is
necessary for it to do its job properly.
Side Effects Caused By This Change
========================================================================
None expected.1 parent e6b09ad commit 7ab80e3
File tree
4 files changed
+47
-8
lines changed- lib/ruby-progressbar
- calculators
- spec/lib/ruby-progressbar
- calculators
4 files changed
+47
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
5 | 6 | | |
6 | | - | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
| 15 | + | |
| 16 | + | |
12 | 17 | | |
13 | 18 | | |
14 | | - | |
| 19 | + | |
15 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
16 | 39 | | |
17 | 40 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 41 | | |
22 | 42 | | |
23 | 43 | | |
24 | | - | |
| 44 | + | |
25 | 45 | | |
26 | 46 | | |
27 | 47 | | |
| |||
44 | 64 | | |
45 | 65 | | |
46 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
47 | 73 | | |
48 | 74 | | |
49 | 75 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
44 | 57 | | |
45 | 58 | | |
46 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| |||
0 commit comments