Class: Smalruby::EventHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/smalruby/event_handler.rb

Overview

イベントハンドラを表現するクラス

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, options, &block) ⇒ EventHandler

Returns a new instance of EventHandler.

Parameters:

  • object (Object)

    操作対象

  • options (Array)

    イベントハンドラのオプション

  • block (Proc)

    イベントハンドラ



12
13
14
15
16
# File 'lib/smalruby/event_handler.rb', line 12

def initialize(object, options, &block)
  @object = object
  @options = options
  @block = block
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



7
8
9
# File 'lib/smalruby/event_handler.rb', line 7

def block
  @block
end

#objectObject

Returns the value of attribute object.



5
6
7
# File 'lib/smalruby/event_handler.rb', line 5

def object
  @object
end

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/smalruby/event_handler.rb', line 6

def options
  @options
end

Instance Method Details

#call(*args) ⇒ Object



18
19
20
21
22
# File 'lib/smalruby/event_handler.rb', line 18

def call(*args)
  return Thread.start(@object, @block) { |object, block|
           object.instance_exec(*args, &block)
         }
end