Class: Utils::IRB::Shell::ConstantWrapper

Inherits:
WrapperBase show all
Defined in:
lib/utils/irb.rb

Overview

A wrapper class for Ruby constant objects that provides enhanced introspection and display capabilities.

This class extends WrapperBase to create specialized wrappers for Ruby constant objects, offering detailed information about constants including their names and associated classes. It facilitates interactive exploration of Ruby constants in environments like IRB by providing structured access to constant metadata and enabling sorting and comparison operations based on constant descriptions.

Instance Attribute Summary collapse

Attributes inherited from WrapperBase

#description, #name

Instance Method Summary collapse

Methods inherited from WrapperBase

#<=>, #==, #hash

Constructor Details

#initialize(obj, name) ⇒ Utils::Patterns::Pattern

The initialize method sets up a new instance with the provided object and name.

This method configures the instance by storing a reference to the object’s class and creating a description string that combines the name with the class name.

Parameters:

  • obj (Object)

    the object whose class will be referenced

  • name (String)

    the name to be used in the description



407
408
409
410
411
# File 'lib/utils/irb.rb', line 407

def initialize(obj, name)
  super(name)
  @klass = obj.class
  @description = "#@name:#@klass"
end

Instance Attribute Details

#klassObject (readonly)

The klass reader method provides access to the class value stored in the instance.

Returns:

  • (Object)

    the class value



416
417
418
# File 'lib/utils/irb.rb', line 416

def klass
  @klass
end