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

- (Callback) initialize(watcher, event, prok, oneshot = false)

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

- (Object) event (readonly)

Returns the value of attribute event



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

def event
  @event
end

- (Object) oneshot (readonly)

Returns the value of attribute oneshot



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

def oneshot
  @oneshot
end

- (Object) prok (readonly)

Returns the value of attribute prok



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

def prok
  @prok
end

Instance Method Details

- (Object) call(*args)

Execute callback



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

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

- (Object) remove

Remove callback from watcher



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

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