class Eyecare::Alert
Constants
- DEFAULT_BEEP_END
- DEFAULT_BEEP_PLAYER
- DEFAULT_BEEP_START
- DEFAULT_ICON_PATH
- DEFAULT_MESSAGE
- DEFAULT_TIMEOUT
Attributes
beep[RW]
icon_path[RW]
message[RW]
timeout[RW]
Public Class Methods
new()
click to toggle source
# File lib/eyecare/alert.rb, line 61 def initialize self.init end
Public Instance Methods
init(options = {})
click to toggle source
# File lib/eyecare/alert.rb, line 36 def init(options = {}) @message = options.fetch(:message, DEFAULT_MESSAGE) @timeout = options.fetch(:timeout, DEFAULT_TIMEOUT) @icon_path = options.fetch(:icon, DEFAULT_ICON_PATH) beep_start = DEFAULT_BEEP_START beep_end = DEFAULT_BEEP_END beep_player = DEFAULT_BEEP_PLAYER if options[:beep] beep_start = options[:beep][:start] if options[:beep][:start] beep_end = options[:beep][:end] if options[:beep][:end] beep_player = options[:beep][:player] if options[:beep][:player] end @beep = Beep.new(start: beep_start, end: beep_end, player: beep_player) self end
show()
click to toggle source
# File lib/eyecare/alert.rb, line 54 def show beep.play(:start) notification.show! run_after(self.timeout) { beep.play(:end) } end
Private Instance Methods
notification()
click to toggle source
# File lib/eyecare/alert.rb, line 70 def notification Libnotify.new do |s| s.summary = 'Eyecare' s.body = self.message s.timeout = self.timeout s.urgency = :normal s.icon_path = icon_path end end
run_after(timeout) { || ... }
click to toggle source
# File lib/eyecare/alert.rb, line 65 def run_after(timeout, &block) sleep(timeout) yield end