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, #display_name, #get_device_instance, #handle_new_event, #initialize_device, #load_default_device, #restart_current_component_async, #run, #run!, #run_worker_loop, #send_event, #stop, #stop_threads, #worker_loop

Methods included from Common::Loggable

#display_name, #logger, #progname

Constructor Details

#initialize(name, master, options = {}) ⇒ Buzzer

Returns a new instance of Buzzer.



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

def initialize(name, master, options = {})
  super
  @buzzer = initialize_device
end

Instance Method Details

#clean_upObject



35
36
37
38
# File 'lib/tamashii/agent/buzzer.rb', line 35

def clean_up
  super
  @buzzer.shutdown
end

#default_device_nameObject



12
13
14
# File 'lib/tamashii/agent/buzzer.rb', line 12

def default_device_name
  'Dummy'
end

#get_device_class_name(device_name) ⇒ Object



16
17
18
# File 'lib/tamashii/agent/buzzer.rb', line 16

def get_device_class_name(device_name)
  "Buzzer::#{device_name}"
end

#process_event(event) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tamashii/agent/buzzer.rb', line 20

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