Class: Ocular::Inputs::Handlers

Inherits:
Object
  • Object
show all
Defined in:
lib/ocular/inputs/handlers.rb

Instance Method Summary collapse

Constructor Details

#initializeHandlers

Returns a new instance of Handlers.



7
8
9
# File 'lib/ocular/inputs/handlers.rb', line 7

def initialize
    @handlers = Hash.new
end

Instance Method Details

#get(klass) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/ocular/inputs/handlers.rb', line 11

def get(klass)
    if @handlers[klass]
        return @handlers[klass]
    end

    @handlers[klass] = klass.new(::Ocular::Settings)
    return @handlers[klass]
end

#startObject



20
21
22
23
24
25
26
# File 'lib/ocular/inputs/handlers.rb', line 20

def start()
    puts "Starting handlers..."
    @handlers.each do |name, handler|
        puts "Staring handler #{name} with #{handler}"
        handler.start()
    end
end

#stopObject



28
29
30
31
32
# File 'lib/ocular/inputs/handlers.rb', line 28

def stop()
    @handlers.each do |name, handler|
        handler.stop()
    end
end