Class: Cuetip::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/cuetip/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

Return the logger



23
24
25
# File 'lib/cuetip/config.rb', line 23

def logger
  @logger ||= Klogger.new(:cuetip)
end

#polling_intervalObject

The length of time between polling



11
12
13
# File 'lib/cuetip/config.rb', line 11

def polling_interval
  @polling_interval || 5
end

#worker_threadsObject

The number of worker threads to run



17
18
19
# File 'lib/cuetip/config.rb', line 17

def worker_threads
  @worker_threads || 1
end

Instance Method Details

#callbacksObject

Return all callbacks



35
36
37
# File 'lib/cuetip/config.rb', line 35

def callbacks
  @callbacks ||= Hash.new
end

#emit(event, *args) ⇒ Object

Emit some callbacks



40
41
42
43
44
45
46
# File 'lib/cuetip/config.rb', line 40

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



29
30
31
32
# File 'lib/cuetip/config.rb', line 29

def on(event, &block)
  callbacks[event.to_sym] ||= []
  callbacks[event.to_sym] << block
end