Class: IRB::Notifier::AbstractNotifier (Ruby 2.2.4)
Description: Class : IRB::Notifier::AbstractNotifier - Ruby 2.2.4

- Home
- Core 2.2.4
- Std-lib 2.2.4
- Downloads

Support for the Ruby 2.2 series has ended. See here for reference.

### Home Classes Methods

### In Files

- irb/notifier.rb

### Parent

Object

### Methods

- ::new
- #exec_if
- #notify?
- #pp
- #ppx
- #print
- #printf
- #printn
- #puts

### Class/Module Index

Quicksearch

- IRB::Abort
- IRB::Context
- IRB::ContextExtender
- IRB::ExtendCommandBundle
- IRB::FileInputMethod
- IRB::Frame
- IRB::InputMethod
- IRB::Inspector
- IRB::Irb
- IRB::IrbLoader
- IRB::JobManager
- IRB::LoadAbort
- IRB::MethodExtender
- IRB::Notifier
- IRB::Notifier::AbstractNotifier
- IRB::Notifier::CompositeNotifier
- IRB::Notifier::LeveledNotifier
- IRB::Notifier::NoMsgNotifier
- IRB::OutputMethod
- IRB::ReadlineInputMethod
- IRB::StdioInputMethod
- IRB::StdioOutputMethod
- IRB::WorkSpace
- Object
- XMP
- XMP::StringInputMethod

No matching classes.

# 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) click to toggle source

Creates a new Notifier object

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

### Public Instance Methods

exec_if() click to toggle source

Execute the given block if notifications are enabled.

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

notify?() click to toggle source

A wrapper method used to determine whether notifications are enabled.

Defaults to `true`.

                   # File irb/notifier.rb, line 54
    def notify?
      true
    end

pp(*objs) click to toggle source

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

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

ppx(prefix, *objs) click to toggle source

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 93
    def ppx(prefix, *objs)
      if notify?
        @base_notifier.ppx @prefix+prefix, *objs
      end
    end

print(*opts) click to toggle source

See IRB::OutputMethod#print for more detail.

                   # File irb/notifier.rb, line 59
    def print(*opts)
      @base_notifier.print prefix, *opts if notify?
    end

printf(format, *opts) click to toggle source

See IRB::OutputMethod#printf for more detail.

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

printn(*opts) click to toggle source

See IRB::OutputMethod#printn for more detail.

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

puts(*objs) click to toggle source

See IRB::OutputMethod#puts for more detail.

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