Sha256: 700ca87bb9d4e1d47ef9cb0492d95156cd58e036d07a8c93e1147ec995a3f70c

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 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 $?.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.1 lib/notifiers/base.rb