Class: Notifaction::Type::OSX

Inherits:
Base
  • Object
show all
Defined in:
lib/notifaction/types/osx.rb

Constant Summary

Constants inherited from Base

Base::OK, Base::QUIT, Base::QUIT_SOFT

Instance Attribute Summary

Attributes inherited from Base

#user_conf

Instance Method Summary collapse

Methods inherited from Base

#fire_hooks, #initialize, #ok, #quit, #quit_ok, #quit_soft

Constructor Details

This class inherits a constructor from Notifaction::Type::Base

Instance Method Details

#bubble(message, title) ⇒ Object

Since:

  • 0.1.0



6
7
8
9
10
11
12
13
14
15
# File 'lib/notifaction/types/osx.rb', line 6

def bubble(message, title)
  @response = `osascript -e 'display notification "#{message}" with title "#{title}"'`
  $?.exitstatus == 0

  if fire_hooks(method: __method__, message: message, title: title)
    quit_ok
  else
    quit_soft
  end
end

Since:

  • 0.1.0



19
20
21
22
23
24
25
26
27
28
# File 'lib/notifaction/types/osx.rb', line 19

def modal(message, title, icon = :caution)
  @response = `osascript -e 'tell app "System Events" to display dialog "#{message}" buttons {"OK"} default button 1 with title "#{title}" with icon #{icon}'`
  $?.exitstatus == 0

  if fire_hooks(method: __method__, message: message, title: title)
    quit_ok
  else
    quit_soft
  end
end