Class: Smalruby::EventHandler
- Inherits:
-
Object
- Object
- Smalruby::EventHandler
- Defined in:
- lib/smalruby/event_handler.rb
Overview
イベントハンドラを表現するクラス
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#object ⇒ Object
Returns the value of attribute object.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(object, options, &block) ⇒ EventHandler
constructor
A new instance of EventHandler.
Constructor Details
#initialize(object, options, &block) ⇒ EventHandler
Returns a new instance of EventHandler.
12 13 14 15 16 17 |
# File 'lib/smalruby/event_handler.rb', line 12 def initialize(object, , &block) @object = object @options = @block = block @running = false end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
7 8 9 |
# File 'lib/smalruby/event_handler.rb', line 7 def block @block end |
#object ⇒ Object
Returns the value of attribute object.
5 6 7 |
# File 'lib/smalruby/event_handler.rb', line 5 def object @object end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/smalruby/event_handler.rb', line 6 def @options end |
Instance Method Details
#call(*args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/smalruby/event_handler.rb', line 19 def call(*args) return nil if @running return Thread.start(@object, @block) { |object, block| begin @running = true object.instance_exec(*args, &block) ensure @running = false end } end |