Sha256: 8f5376bfcec0b9980631c27151d39b37a4a64ded8a6443a08da3c995f9dc888d

Contents?: true

Size: 498 Bytes

Versions: 3

Compression:

Stored size: 498 Bytes

Contents

# frozen_string_literal: true

module Helium
  class Console
    define_formatter_for Module do
      def call
        light_yellow(object.name || anonymous_text)
      end

      private

      def anonymous_text
        closest = (object.ancestors.grep(Class) - [Object, BasicObject]).find(&:name)&.name

        signature = if closest
          "subclass of #{closest}"
        else
          object.class.name.downcase
        end
        "(anonymous #{signature})"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
helium-console-0.1.11 lib/helium/console/registry/module.rb
helium-console-0.1.10 lib/helium/console/registry/module.rb
helium-console-0.1.9 lib/helium/console/registry/module.rb