@@ -19,13 +19,12 @@ class Time
1919 } . freeze
2020
2121 def initialize ( options = { } )
22- self . out_of_bounds_time_format = options [ :out_of_bounds_time_format ]
23- self . timer = options [ :timer ]
24- self . progress = options [ :progress ]
22+ self . timer = options [ :timer ]
23+ self . progress = options [ :progress ]
2524 end
2625
27- def estimated_with_label
28- "#{ ESTIMATED_LABEL } : #{ estimated } "
26+ def estimated_with_label ( out_of_bounds_time_format = nil )
27+ "#{ ESTIMATED_LABEL } : #{ estimated ( out_of_bounds_time_format ) } "
2928 end
3029
3130 def elapsed_with_label
@@ -35,21 +34,15 @@ def elapsed_with_label
3534 protected
3635
3736 def estimated_with_no_oob
38- self . out_of_bounds_time_format = nil
39-
40- estimated_with_elapsed_fallback
37+ estimated_with_elapsed_fallback ( nil )
4138 end
4239
4340 def estimated_with_unknown_oob
44- self . out_of_bounds_time_format = :unknown
45-
46- estimated_with_elapsed_fallback
41+ estimated_with_elapsed_fallback ( :unknown )
4742 end
4843
4944 def estimated_with_friendly_oob
50- self . out_of_bounds_time_format = :friendly
51-
52- estimated_with_elapsed_fallback
45+ estimated_with_elapsed_fallback ( :friendly )
5346 end
5447
5548 def estimated_wall_clock
@@ -63,29 +56,20 @@ def estimated_wall_clock
6356 strftime ( WALL_CLOCK_FORMAT )
6457 end
6558
66- attr_reader :out_of_bounds_time_format
6759 attr_accessor :timer ,
6860 :progress
6961
70- def out_of_bounds_time_format = ( format )
71- unless OOB_TIME_FORMATS . include? format
72- fail StandardError , "Invalid Out Of Bounds time format. Valid formats are #{ OOB_TIME_FORMATS . inspect } "
73- end
74-
75- @out_of_bounds_time_format = format
76- end
77-
7862 private
7963
80- def estimated
64+ def estimated ( out_of_bounds_time_format )
8165 memo_estimated_seconds_remaining = estimated_seconds_remaining
8266
8367 return OOB_UNKNOWN_TIME_TEXT unless memo_estimated_seconds_remaining
8468
8569 hours , minutes , seconds = timer . divide_seconds ( memo_estimated_seconds_remaining )
8670
8771 if hours > OOB_LIMIT_IN_HOURS && out_of_bounds_time_format
88- OOB_TEXT_TO_FORMAT [ out_of_bounds_time_format ]
72+ OOB_TEXT_TO_FORMAT . fetch ( out_of_bounds_time_format )
8973 else
9074 TIME_FORMAT % [ hours , minutes , seconds ]
9175 end
@@ -99,8 +83,8 @@ def elapsed
9983 TIME_FORMAT % [ hours , minutes , seconds ]
10084 end
10185
102- def estimated_with_elapsed_fallback
103- progress . finished? ? elapsed_with_label : estimated_with_label
86+ def estimated_with_elapsed_fallback ( out_of_bounds_time_format )
87+ progress . finished? ? elapsed_with_label : estimated_with_label ( out_of_bounds_time_format )
10488 end
10589
10690 def estimated_seconds_remaining
0 commit comments