Class: Smalruby3::EventHandler
- Inherits:
-
Object
- Object
- Smalruby3::EventHandler
- Defined in:
- lib/smalruby3/event_handler.rb
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
7 8 9 10 11 12 |
# File 'lib/smalruby3/event_handler.rb', line 7 def initialize(object, , &block) @object = object = @block = block @running = false end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
5 6 7 |
# File 'lib/smalruby3/event_handler.rb', line 5 def block @block end |
#object ⇒ Object
Returns the value of attribute object.
3 4 5 |
# File 'lib/smalruby3/event_handler.rb', line 3 def object @object end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/smalruby3/event_handler.rb', line 4 def end |
Instance Method Details
#call(*args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/smalruby3/event_handler.rb', line 14 def call(*args) if @running return nil end return Thread.start(@object, @block) { |object, block| begin @running = true object.instance_exec(*args, &block) ensure @running = false end } end |