Module: Kernel

Defined in:
lib/n.rb

Instance Method Summary collapse

Instance Method Details

#n(*args, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/n.rb', line 9

def n(*args, &block)
  args.push(block) if block

  messages =
    if args.empty?
      [nil.pretty_inspect]
    else
      args.map { |i| i.pretty_inspect }
    end

  messages.each do |i|
    system 'notify-send',
           "--urgency=#{$n_priority}",
           "--expire-time=#{$n_expire}",
           "--",
           $0,
           CGI.escapeHTML(i)
  end

  if args.empty?
    nil
  elsif args.size == 1
    args.first
  else
    args
  end
end