Class: IRB::Notifier::AbstractNotifier (Ruby 2.3.4)

IRB::Notifier::AbstractNotifier

An abstract class, or superclass, for CompositeNotifier and LeveledNotifier to inherit. It provides several wrapper methods for the OutputMethod object used by the Notifier.

Attributes

prefix[R]

The prefix for this Notifier, which is appended to all objects being inspected during output.

Public Class Methods

new(prefix, base_notifier)

Creates a new Notifier object

 
               # File irb/notifier.rb, line 43
def initialize(prefix, base_notifier)
  @prefix = prefix
  @base_notifier = base_notifier
end
            

Public Instance Methods

exec_if()

Execute the given block if notifications are enabled.

 
               # File irb/notifier.rb, line 101
def exec_if
  yield(@base_notifier) if notify?
end
            
notify?()

A wrapper method used to determine whether notifications are enabled.

Defaults to true.

 
               # File irb/notifier.rb, line 55
def notify?
  true
end
            
pp(*objs)

Same as ppx, except it uses the prefix given during object initialization. See IRB::OutputMethod#ppx for more detail.

 
               # File irb/notifier.rb, line 84
def pp(*objs)
  if notify?
    @base_notifier.ppx @prefix, *objs
  end
end
            
ppx(prefix, *objs)

Same as pp, except it concatenates the given prefix with the prefix given during object initialization.

See IRB::OutputMethod#ppx for more detail.

 
               # File irb/notifier.rb, line 94
def ppx(prefix, *objs)
  if notify?
    @base_notifier.ppx @prefix+prefix, *objs
  end
end
            
printf(format, *opts)

See IRB::OutputMethod#printf for more detail.

 
               # File irb/notifier.rb, line 70
def printf(format, *opts)
  @base_notifier.printf(prefix + format, *opts) if notify?
end
            
printn(*opts)

See IRB::OutputMethod#printn for more detail.

 
               # File irb/notifier.rb, line 65
def printn(*opts)
  @base_notifier.printn prefix, *opts if notify?
end
            
puts(*objs)

See IRB::OutputMethod#puts for more detail.

 
               # File irb/notifier.rb, line 75
def puts(*objs)
  if notify?
    @base_notifier.puts(*objs.collect{|obj| prefix + obj.to_s})
  end
end