Class: Tamashii::Agent::Buzzer

Inherits:
Component show all
Defined in:
lib/tamashii/agent/buzzer.rb

Instance Method Summary collapse

Methods inherited from Component

#check_new_event, #handle_new_event, #restart_current_component_async, #run, #run!, #run_worker_loop, #send_event, #stop, #stop_threads, #worker_loop

Methods included from Common::Loggable

#logger, #progname

Constructor Details

#initialize(master) ⇒ Buzzer

Returns a new instance of Buzzer.



8
9
10
11
12
# File 'lib/tamashii/agent/buzzer.rb', line 8

def initialize(master)
  super
  @buzzer = Adapter::Buzzer.object
  logger.debug "Using buzzer instance: #{@buzzer.class}"
end

Instance Method Details

#clean_upObject



29
30
31
32
# File 'lib/tamashii/agent/buzzer.rb', line 29

def clean_up
  super
  @buzzer.stop
end

#process_event(event) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tamashii/agent/buzzer.rb', line 14

def process_event(event)
  case event.type
  when Event::BEEP
    logger.debug "Beep: #{event.body}"
    case event.body
    when "ok"
      @buzzer.play_ok
    when "no"
      @buzzer.play_no
    when "error"
      @buzzer.play_error
    end
  end
end