Class: MPlayer::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_mplayer/callback.rb

Overview

:nodoc:all

Instance Method Summary collapse

Constructor Details

#initialize(callback_options) ⇒ Callback

Returns a new instance of Callback.



3
4
5
6
7
# File 'lib/easy_mplayer/callback.rb', line 3

def initialize(callback_options)
  @block = callback_options[:block]
  @type  = callback_options[:type]
  @scope = callback_options[:scope]
end

Instance Method Details

#run!(args) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/easy_mplayer/callback.rb', line 9

def run!(args)
  unless @block.nil?
    case @type
    when :instance then @block.call(*args)
    when :class    then @scope.instance_exec(*args, &@block)
    end
  end
end