Sha256: 69f34b0d85ce7b4ffcc5d8059ec0b2b056027376281e03ad4c6756730829d63c

Contents?: true

Size: 814 Bytes

Versions: 2

Compression:

Stored size: 814 Bytes

Contents

module Notifiers
  class NotifySend < Notifiers::Base
    COMMAND = 'notify-send'

    def urgency(level)
      @urgency = level.to_s
      self
    end

    def expire_time(time)
      @expire_time = time
      self
    end

    def hint(values)
      @hint = values.collect.each { |element| element.to_s}.join(':')
      self
    end

    def to_s
      command = COMMAND.clone
      [:hint, :priority, :icon, :urgency].each do |option|
        variable = instance_variable_get("@#{option}")
        command << " --#{option}=#{variable}" if variable
      end
      command << " --expire-time=#{@expire_time}" if @expire_time
      [:title, :message].each do |option|
        variable = instance_variable_get("@#{option}")
        command << " '#{variable}'" if variable
      end
      command
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
notifiers-1.2.2 lib/notifiers/notify_send.rb
notifiers-1.2.1 lib/notifiers/notify_send.rb