Class: SoundNotifier

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

Overview

SoundNotifier library for notiffany

Defined Under Namespace

Classes: UnsupportedPlatform

Constant Summary collapse

DATA_PATH =
File.expand_path('../../data', __FILE__)
VERSION =
'0.1.2'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ SoundNotifier

Returns a new instance of SoundNotifier.



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

def initialize(type)
  @type = type
  check_host_supported
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



18
19
20
# File 'lib/sound_notifier.rb', line 18

def type
  @type
end

Class Method Details

.execute(type = :notify) ⇒ Object



21
22
23
# File 'lib/sound_notifier.rb', line 21

def execute(type = :notify)
  new(type).notify
end

Instance Method Details

#kernelObject



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

def kernel
  @kernel ||= Kernel
end

#notifyObject



35
36
37
38
# File 'lib/sound_notifier.rb', line 35

def notify
  return unless File.exist?(sound_file) && play_command
  @sound_thread = Thread.new { play_file }
end