Class: Cuetip::Config
- Inherits:
-
Object
- Object
- Cuetip::Config
- Defined in:
- lib/cuetip/config.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Return the logger.
-
#polling_interval ⇒ Object
The length of time between polling.
-
#worker_threads ⇒ Object
The number of worker threads to run.
Instance Method Summary collapse
-
#callbacks ⇒ Object
Return all callbacks.
-
#emit(event, *args) ⇒ Object
Emit some callbacks.
-
#on(event, &block) ⇒ Object
Define a job event callback.
Instance Attribute Details
#logger ⇒ Object
Return the logger
22 23 24 |
# File 'lib/cuetip/config.rb', line 22 def logger @logger ||= Logger.new(STDOUT) end |
#polling_interval ⇒ Object
The length of time between polling
10 11 12 |
# File 'lib/cuetip/config.rb', line 10 def polling_interval @polling_interval || 5 end |
#worker_threads ⇒ Object
The number of worker threads to run
16 17 18 |
# File 'lib/cuetip/config.rb', line 16 def worker_threads @worker_threads || 1 end |
Instance Method Details
#callbacks ⇒ Object
Return all callbacks
34 35 36 |
# File 'lib/cuetip/config.rb', line 34 def callbacks @callbacks ||= Hash.new end |
#emit(event, *args) ⇒ Object
Emit some callbacks
39 40 41 42 43 44 45 |
# File 'lib/cuetip/config.rb', line 39 def emit(event, *args) return unless callbacks[event.to_sym] callbacks[event.to_sym].each do |callback| callback.call(*args) end end |
#on(event, &block) ⇒ Object
Define a job event callback
28 29 30 31 |
# File 'lib/cuetip/config.rb', line 28 def on(event, &block) callbacks[event.to_sym] ||= [] callbacks[event.to_sym] << block end |