Class: Omnizip::Progress::CallbackReporter
- Inherits:
-
ProgressReporter
- Object
- ProgressReporter
- Omnizip::Progress::CallbackReporter
- Defined in:
- lib/omnizip/progress/callback_reporter.rb
Overview
Progress reporter that calls a user-provided Ruby block.
This reporter allows users to provide custom callbacks for progress updates, enabling integration with web frameworks, GUI applications, or custom logging systems.
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
Instance Method Summary collapse
-
#initialize(&callback) {|progress| ... } ⇒ CallbackReporter
constructor
Initialize a new callback reporter.
-
#report(progress) ⇒ Object
Report progress by calling the callback.
Methods inherited from ProgressReporter
Constructor Details
#initialize(&callback) {|progress| ... } ⇒ CallbackReporter
Initialize a new callback reporter
21 22 23 24 |
# File 'lib/omnizip/progress/callback_reporter.rb', line 21 def initialize(&callback) super() @callback = callback || proc { |_| } end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
15 16 17 |
# File 'lib/omnizip/progress/callback_reporter.rb', line 15 def callback @callback end |
Instance Method Details
#report(progress) ⇒ Object
Report progress by calling the callback
29 30 31 |
# File 'lib/omnizip/progress/callback_reporter.rb', line 29 def report(progress) callback.call(progress) end |