Class: IRB::Notifier::CompositeNotifier (Ruby 2.7.5)
Description: Class : IRB::Notifier::CompositeNotifier - Ruby 2.7.5

### Home Classes Methods

### In Files

- irb/notifier.rb

### Parent

IRB::Notifier::AbstractNotifier

### Methods

- ::new
- #def_notifier
- #level=
- #level_notifier=

### Class/Module Index

Quicksearch

- Binding
- IRB::Abort
- IRB::Canvas
- IRB::Color
- IRB::Color::SymbolState
- IRB::Context
- IRB::ContextExtender
- IRB::ExtendCommandBundle
- IRB::FileInputMethod
- IRB::Frame
- IRB::Frame::FrameOverflow
- IRB::Frame::FrameUnderflow
- IRB::History
- IRB::InputMethod
- IRB::Inspector
- IRB::Irb
- IRB::IrbLoader
- IRB::JobManager
- IRB::LoadAbort
- IRB::MethodExtender
- IRB::Notifier
- IRB::Notifier::AbstractNotifier
- IRB::Notifier::CompositeNotifier
- IRB::Notifier::ErrUndefinedNotifier
- IRB::Notifier::ErrUnrecognizedLevel
- IRB::Notifier::LeveledNotifier
- IRB::Notifier::NoMsgNotifier
- IRB::OutputMethod
- IRB::OutputMethod::NotImplementedError
- IRB::ReadlineInputMethod
- IRB::ReidlineInputMethod
- IRB::RubyModel
- IRB::StdioInputMethod
- IRB::StdioOutputMethod
- IRB::Vec
- IRB::WorkSpace
- Object
- XMP
- XMP::StringInputMethod

No matching classes.

# IRB::Notifier::CompositeNotifier

A class that can be used to create a group of notifier objects with the intent of representing a leveled notification system for irb.

This class will allow you to generate other notifiers, and assign them the appropriate level for output.

The `Notifier` class provides a class-method `Notifier.def_notifier` to create a new composite notifier. Using the first composite notifier object you create, sibling notifiers can be initialized with `def_notifier`.

### Attributes

level[R]

Returns the leveled notifier for this object

level_notifier[R]

Returns the leveled notifier for this object

notifiers[R]

List of notifiers in the group

### Public Class Methods

new(prefix, base_notifier) click to toggle source

Create a new composite notifier object with the given `prefix`, and `base_notifier` to use for output.

                   # File irb/notifier.rb, line 123
    def initialize(prefix, base_notifier)
      super

      @notifiers = [D_NOMSG]
      @level_notifier = D_NOMSG
    end

### Public Instance Methods

def_notifier(level, prefix = "") click to toggle source

Creates a new `LeveledNotifier` in the composite `notifiers` group.

The given `prefix` will be assigned to the notifier, and `level` will be used as the index of the `notifiers` Array.

This method returns the newly created instance.

                   # File irb/notifier.rb, line 139
    def def_notifier(level, prefix = "")
      notifier = LeveledNotifier.new(self, level, prefix)
      @notifiers[level] = notifier
      notifier
    end

level=(value) click to toggle source
Alias for: level_notifier=
level_notifier=(value) click to toggle source

Sets the leveled notifier for this object.

When the given `value` is an instance of `AbstractNotifier`, `level_notifier` is set to the given object.

When an Integer is given, `level_notifier` is set to the notifier at the index `value` in the `notifiers` Array.

If no notifier exists at the index `value` in the `notifiers` Array, an `ErrUndefinedNotifier` exception is raised.

An `ErrUnrecognizedLevel` exception is raised if the given `value` is not found in the existing `notifiers` Array, or an instance of `AbstractNotifier`

                   # File irb/notifier.rb, line 163
    def level_notifier=(value)
      case value
      when AbstractNotifier
        @level_notifier = value
      when Integer
        l = @notifiers[value]
        raise ErrUndefinedNotifier, value unless l
        @level_notifier = l
      else
        raise ErrUnrecognizedLevel, value unless l
      end
    end

Also aliased as: level=