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



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

def logger
  @logger ||= Logger.new(STDOUT)
end

#polling_intervalObject

The length of time between polling



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

def polling_interval
  @polling_interval || 5
end

#worker_threadsObject

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

#callbacksObject

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