Sha256: cbbef1cfa94aa66e40035a9c86e6f955136193d693a7f5a121a16fe026da208a

Contents?: true

Size: 827 Bytes

Versions: 4

Compression:

Stored size: 827 Bytes

Contents

module Notifaction
  module Type
    class OSX < Type::Base
      #
      # @since 0.1.0
      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
      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
notifaction-0.4.4 lib/notifaction/types/osx.rb
notifaction-0.4.3 lib/notifaction/types/osx.rb
notifaction-0.4.2 lib/notifaction/types/osx.rb
notifaction-0.4.1 lib/notifaction/types/osx.rb