class YoutubeDL::Listener

Public Class Methods

new() click to toggle source
# File lib/youtube_dl/listener.rb, line 3
def initialize
  @callbacks = Hash.new { |h, k| h[k] = [] }
end

Public Instance Methods

call(event, state:, line: nil) click to toggle source
# File lib/youtube_dl/listener.rb, line 7
def call(event, state:, line: nil)
  (@callbacks[event] + @callbacks[:any]).each do |cb|
    cb.call(state: state, line: line)
  end
end
register(event, &block) click to toggle source
# File lib/youtube_dl/listener.rb, line 13
def register(event, &block)
  @callbacks[event] << block
end