Module: Kernel

Defined in:
lib/g.rb

Instance Method Summary collapse

Instance Method Details

#g(*args, &block) ⇒ Object



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
36
37
38
39
# File 'lib/g.rb', line 10

def g(*args, &block)
  
  options = {}
  if args.last.class == Hash
    options = args.pop
  end
  
  title = options[:title] || 'g'

  growl = Growl.new $g_host, title, [$0]

  args.push(block) if block

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

  messages.each { |i| growl.notify $0, title, i, $g_priority, $g_sticky }

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