Module: Dux::InspectID

Extended by:
InspectID
Included in:
Dux, InspectID, NullObject
Defined in:
lib/dux/inspect_id.rb

Overview

Calculate the object's inspection id

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inspect_id(object = self) ⇒ String

Note:

This is currently limited to the implementation used in MRI. Rubinius and JRuby have their own implementations that are not currently served by this.

Calculates the id shown in the default version of #inspect methods.

Parameters:

  • object (Object) (defaults to: self)

Returns:

  • (String)


13
14
15
# File 'lib/dux/inspect_id.rb', line 13

def inspect_id(object = self)
  "0x%0.14x" % ( object.object_id << 1 )
end

Instance Method Details

#inspect_id(object = self) ⇒ String

Note:

This is currently limited to the implementation used in MRI. Rubinius and JRuby have their own implementations that are not currently served by this.

Calculates the id shown in the default version of #inspect methods.

Parameters:

  • object (Object) (defaults to: self)

Returns:

  • (String)


13
14
15
# File 'lib/dux/inspect_id.rb', line 13

def inspect_id(object = self)
  "0x%0.14x" % ( object.object_id << 1 )
end