Class: ZugZug::Soundboard

Inherits:
Object
  • Object
show all
Defined in:
lib/zug_zug/soundboard.rb

Constant Summary collapse

HORDE_SOUNDS =
{
  zug_zug: "zug_zug.wav",
  work_complete: "work_complete.wav"
}
ALLIANCE_SOUNDS =
{
  zug_zug: "alright.wav",
  work_complete: "jobs_done.wav"
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(faction, plugin: default_plugin) ⇒ Soundboard

Returns a new instance of Soundboard.



26
27
28
29
# File 'lib/zug_zug/soundboard.rb', line 26

def initialize(faction, plugin: default_plugin)
  @_board  = Soundboard.board_for faction
  @_plugin = plugin
end

Class Method Details

.board_for(faction) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/zug_zug/soundboard.rb', line 15

def self.board_for(faction)
  case faction
  when HORDE
    HORDE_SOUNDS
  when ALLIANCE
    ALLIANCE_SOUNDS
  else
    fail ArgumentError, "#{faction} is not a valid faction (valid factions are #{HORDE} and #{ALLIANCE})"
  end
end

Instance Method Details

#play(file) ⇒ Object



39
40
41
# File 'lib/zug_zug/soundboard.rb', line 39

def play(file)
  @_plugin.call(file)
end

#sound_file(sound) ⇒ Object



43
44
45
46
# File 'lib/zug_zug/soundboard.rb', line 43

def sound_file(sound)
  file_name = @_board.fetch sound
  File.join __dir__, "sounds", file_name
end

#work_is_overObject



35
36
37
# File 'lib/zug_zug/soundboard.rb', line 35

def work_is_over
  play sound_file(:work_complete)
end

#work_startsObject



31
32
33
# File 'lib/zug_zug/soundboard.rb', line 31

def work_starts
  play sound_file(:zug_zug)
end