Class: Bowline::Watcher::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/bowline/watcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(watcher, event, prok, oneshot = false) ⇒ Callback

Returns a new instance of Callback.



71
72
73
74
75
76
# File 'lib/bowline/watcher.rb', line 71

def initialize(watcher, event, prok, oneshot = false)
  @watcher = watcher
  @event   = event
  @prok    = prok
  @oneshot = oneshot
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



69
70
71
# File 'lib/bowline/watcher.rb', line 69

def event
  @event
end

#oneshotObject (readonly)

Returns the value of attribute oneshot.



69
70
71
# File 'lib/bowline/watcher.rb', line 69

def oneshot
  @oneshot
end

#prokObject (readonly)

Returns the value of attribute prok.



69
70
71
# File 'lib/bowline/watcher.rb', line 69

def prok
  @prok
end

Instance Method Details

#call(*args) ⇒ Object

Execute callback



79
80
81
82
# File 'lib/bowline/watcher.rb', line 79

def call(*args)
	prok.call(*args)
	remove if oneshot
end

#removeObject

Remove callback from watcher



85
86
87
# File 'lib/bowline/watcher.rb', line 85

def remove
	@watcher.remove(@event, @prok)
end