123456789_123456789_123456789_123456789_123456789_

Class: IRB::Notifier::LeveledNotifier

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
self, Comparable, AbstractNotifier
Inherits: IRB::Notifier::AbstractNotifier
Defined in: lib/irb/notifier.rb

Overview

A leveled notifier is comparable to the composite group from CompositeNotifier#notifiers.

Class Method Summary

AbstractNotifier - Inherited

.new

Creates a new ::IRB::Notifier object.

Instance Attribute Summary

  • #level readonly

    The current level of this notifier object.

  • #notify? ⇒ Boolean readonly

    Whether to output messages to the output method, depending on the level of this notifier object.

AbstractNotifier - Inherited

#notify?

A wrapper method used to determine whether notifications are enabled.

#prefix

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

Instance Method Summary

  • #<=>(other)

    Compares the level of this notifier object with the given other notifier.

AbstractNotifier - Inherited

#exec_if

Execute the given block if notifications are enabled.

#pp

Same as #ppx, except it uses the #prefix given during object initialization.

#ppx

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

#print

See OutputMethod#print for more detail.

#printf

See OutputMethod#printf for more detail.

#printn

See OutputMethod#printn for more detail.

#puts

See OutputMethod#puts for more detail.

Constructor Details

.new(base, level, prefix) ⇒ LeveledNotifier

Create a new leveled notifier with the given base, and prefix to send to AbstractNotifier.new

The given #level is used to compare other leveled notifiers in the CompositeNotifier group to determine whether or not to output notifications.

[ GitHub ]

  
# File 'lib/irb/notifier.rb', line 184

def initialize(base, level, prefix)
  super(prefix, base)

  @level = level
end

Instance Attribute Details

#level (readonly)

The current level of this notifier object

[ GitHub ]

  
# File 'lib/irb/notifier.rb', line 191

attr_reader :level

#notify?Boolean (readonly)

Whether to output messages to the output method, depending on the level of this notifier object.

[ GitHub ]

  
# File 'lib/irb/notifier.rb', line 203

def notify?
  @base_notifier.level >= self
end

Instance Method Details

#<=>(other)

Compares the level of this notifier object with the given other notifier.

See the Comparable module for more information.

[ GitHub ]

  
# File 'lib/irb/notifier.rb', line 197

def <=>(other)
  @level <=> other.level
end