class Rbtclk::SoundPlayer

Public Class Methods

new() click to toggle source
# File lib/rbtclk/sound_player.rb, line 10
def initialize
  sound_file_path = File.expand_path("../../../sound/bell.mp3", __FILE__)

  @command_line = if command_exist?("afplay")
                    "afplay #{sound_file_path}"
                  elsif command_exist?("mpg123")
                    "mpg123 -q #{sound_file_path}"
                  else
                    ":" # do noghing
                  end
end

Public Instance Methods

play() click to toggle source
# File lib/rbtclk/sound_player.rb, line 22
def play
  spawn @command_line
end

Private Instance Methods

command_exist?(command) click to toggle source
# File lib/rbtclk/sound_player.rb, line 28
def command_exist?(command)
  Open3.capture3("which #{command}")[2].success?
end