Class: SharedTools::Tools::Notification::BaseDriver

Inherits:
Object
  • Object
show all
Defined in:
lib/shared_tools/tools/notification/base_driver.rb

Overview

Abstract base class for platform-specific notification drivers. Subclasses must implement notify, alert, and speak.

Direct Known Subclasses

LinuxDriver, MacDriver, NullDriver

Instance Method Summary collapse

Instance Method Details

#alert(message:, title: nil, buttons: ['OK'], default_button: nil) ⇒ Hash

Show a modal dialog and wait for the user to click a button.

Parameters:

  • message (String)
  • title (String, nil) (defaults to: nil)
  • buttons (Array<String>) (defaults to: ['OK'])
  • default_button (String, nil) (defaults to: nil)

Returns:

  • (Hash)

    includes :button with the label of the clicked button

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/shared_tools/tools/notification/base_driver.rb', line 27

def alert(message:, title: nil, buttons: ['OK'], default_button: nil)
  raise NotImplementedError, "#{self.class}##{__method__} undefined"
end

#notify(message:, title: nil, subtitle: nil, sound: nil) ⇒ Hash

Show a non-blocking desktop banner notification.

Parameters:

  • message (String)
  • title (String, nil) (defaults to: nil)
  • subtitle (String, nil) (defaults to: nil)
  • sound (String, nil) (defaults to: nil)

Returns:

  • (Hash)

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/shared_tools/tools/notification/base_driver.rb', line 16

def notify(message:, title: nil, subtitle: nil, sound: nil)
  raise NotImplementedError, "#{self.class}##{__method__} undefined"
end

#speak(text:, voice: nil, rate: nil) ⇒ Hash

Speak text aloud using text-to-speech.

Parameters:

  • text (String)
  • voice (String, nil) (defaults to: nil)
  • rate (Integer, nil) (defaults to: nil)

    words per minute

Returns:

  • (Hash)

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/shared_tools/tools/notification/base_driver.rb', line 37

def speak(text:, voice: nil, rate: nil)
  raise NotImplementedError, "#{self.class}##{__method__} undefined"
end