Sha256: 3dc862ee3824dc56a1ab6802cf182f9d21c8325e3ea83852de95e7141d8b43a8

Contents?: true

Size: 915 Bytes

Versions: 1

Compression:

Stored size: 915 Bytes

Contents

module Notifiers
  class Base
    def self.inherited(subclass)
      @subclasses ||= []
      @subclasses.push(subclass)
      @subclasses
    end

    def self.subclasses
      @subclasses
    end

    def self.installed?
      false
    end

    def self.darwin?
      platform?(/darwin/)
    end

    def self.platform?(name)
      RbConfig::CONFIG['host_os'] =~ name or RUBY_PLATFORM =~ name
    end

    def self.command?(command)
      `which #{command}` and $?.to_i.zero?
    end

    def notify
      notification = system(to_s)

      puts install_instructions unless notification or install_instructions.empty?

      notification
    end
    alias :notify! :notify

    def message(text)
      @message = text
      self
    end

    def title(text)
      @title = text
      self
    end

    def image(icon)
      @icon = icon
      self
    end

    def install_instructions
      ''
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
notifiers-1.2.2 lib/notifiers/base.rb