An abstract class, or superclass, for CompositeNotifier and LeveledNotifier to inherit. It provides several wrapper methods for the OutputMethod object used by the Notifier.
| [R] | prefix | The |
Creates a new Notifier object
Source: show
# File lib/irb/notifier.rb, line 42 def initialize(prefix, base_notifier) @prefix = prefix @base_notifier = base_notifier end
Execute the given block if notifications are enabled.
Source: show
# File lib/irb/notifier.rb, line 100 def exec_if yield(@base_notifier) if notify? end
A wrapper method used to determine whether notifications are enabled.
Defaults to true.
Source: show
# File lib/irb/notifier.rb, line 54 def notify? true end
Same as ppx, except it uses the prefix given during object initialization. See IRB::OutputMethod#ppx for more detail.
Source: show
# File lib/irb/notifier.rb, line 83 def pp(*objs) if notify? @base_notifier.ppx @prefix, *objs end end
Same as pp, except it
concatenates the given prefix with the prefix given during
object initialization.
See IRB::OutputMethod#ppx for more detail.
Source: show
# File lib/irb/notifier.rb, line 93 def ppx(prefix, *objs) if notify? @base_notifier.ppx @prefix+prefix, *objs end end
See IRB::OutputMethod#print for more detail.
Source: show
# File lib/irb/notifier.rb, line 59 def print(*opts) @base_notifier.print prefix, *opts if notify? end
See IRB::OutputMethod#printf for more detail.
Source: show
# File lib/irb/notifier.rb, line 69 def printf(format, *opts) @base_notifier.printf(prefix + format, *opts) if notify? end
See IRB::OutputMethod#printn for more detail.
Source: show
# File lib/irb/notifier.rb, line 64 def printn(*opts) @base_notifier.printn prefix, *opts if notify? end
See IRB::OutputMethod#puts for more detail.
Source: show
# File lib/irb/notifier.rb, line 74 def puts(*objs) if notify? @base_notifier.puts(*objs.collect{|obj| prefix + obj.to_s}) end end