Class: Omnizip::Progress::CallbackReporter

Inherits:
ProgressReporter show all
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

Instance Method Summary collapse

Methods inherited from ProgressReporter

#finish, #start

Constructor Details

#initialize(&callback) {|progress| ... } ⇒ CallbackReporter

Initialize a new callback reporter

Parameters:

  • callback (Proc)

    Block to call with progress updates

Yields:

  • (progress)

    Yields progress tracker to the block



21
22
23
24
# File 'lib/omnizip/progress/callback_reporter.rb', line 21

def initialize(&callback)
  super()
  @callback = callback || proc { |_| }
end

Instance Attribute Details

#callbackObject (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

Parameters:



29
30
31
# File 'lib/omnizip/progress/callback_reporter.rb', line 29

def report(progress)
  callback.call(progress)
end