Module: Kernel

Defined in:
lib/mw.rb

Constant Summary collapse

MEOW_INSTANCE =
Meow.new('Kernel.mw')

Instance Method Summary collapse

Instance Method Details

#mw(*things) ⇒ Object Also known as: mw3



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mw.rb', line 7

def mw(*things)
  args, opts =
    if things[-1].kind_of?(Hash) && things[-1].has_key?(:priority)
      [things[0..-2], things[-1]]
    else
      [things, {:priority => 0}]
    end
  messages =
    if args.empty?
      [nil.pretty_inspect]
    else
      args.map { |i| i.pretty_inspect }
    end
  messages.each { |i| MEOW_INSTANCE.notify $0, i, opts}

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

#mw1(*args) ⇒ Object Also known as: mw_debug



35
36
37
38
# File 'lib/mw.rb', line 35

def mw1(*args)
  args << {:priority => -2}
  mw(*args)
end

#mw2(*args) ⇒ Object Also known as: mw_info



41
42
43
44
# File 'lib/mw.rb', line 41

def mw2(*args)
  args << {:priority => -1}
  mw(*args)
end

#mw4(*args) ⇒ Object Also known as: mw_warn



49
50
51
52
# File 'lib/mw.rb', line 49

def mw4(*args)
  args << {:priority => 1, :sticky => true}
  mw(*args)
end

#mw5(*args) ⇒ Object Also known as: mw_error



55
56
57
58
# File 'lib/mw.rb', line 55

def mw5(*args)
  args << {:priority => 2, :sticky => true}
  mw(*args)
end

#tapmwObject



31
32
33
# File 'lib/mw.rb', line 31

def tapmw
  tap { mw block_given? ? yield(self) : self }
end