Sha256: 5118325e09574cf6655c54241e27fdc1c1a6c5bb68a8bce3018ad5e6c1f76cdf

Contents?: true

Size: 757 Bytes

Versions: 20

Compression:

Stored size: 757 Bytes

Contents

# frozen_string_literal: true

module RBS
  module Test
    module Guaranteed
      module Inspect
        EQUAL = ::BasicObject.instance_method(:equal?)
        INSPECT = ::Kernel.instance_method(:inspect)
        private_constant :EQUAL, :INSPECT

        module_function def guaranteed_inspect(obj)
          obj.inspect
        rescue NoMethodError
          INSPECT.bind_call(obj)
        end

        def inspect
          string = "<#{self.class.name}:"

          instance_variables.each_with_index do |variable, index|
            string.concat ', ' unless index.zero?
            string.concat "#{variable}: #{guaranteed_inspect(instance_variable_get(variable))}"
          end

          string.concat '>'
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rbs-3.7.0.dev.1 lib/rbs/test/guaranteed.rb
rbs-3.6.1 lib/rbs/test/guaranteed.rb
rbs-3.6.0 lib/rbs/test/guaranteed.rb
rbs-3.6.0.pre.3 lib/rbs/test/guaranteed.rb
rbs-3.6.0.pre.2 lib/rbs/test/guaranteed.rb
rbs-3.6.0.pre.1 lib/rbs/test/guaranteed.rb
rbs-3.6.0.dev.1 lib/rbs/test/guaranteed.rb
rbs-3.5.3 lib/rbs/test/guaranteed.rb
rbs-3.5.2 lib/rbs/test/guaranteed.rb
rbs-3.5.1 lib/rbs/test/guaranteed.rb
rbs-3.5.1.pre.1 lib/rbs/test/guaranteed.rb
rbs-3.5.0 lib/rbs/test/guaranteed.rb
rbs-3.5.0.pre.2 lib/rbs/test/guaranteed.rb
rbs-3.5.0.pre.1 lib/rbs/test/guaranteed.rb
rbs-3.4.4 lib/rbs/test/guaranteed.rb
rbs-3.4.3 lib/rbs/test/guaranteed.rb
rbs-3.4.2 lib/rbs/test/guaranteed.rb
rbs-3.4.1 lib/rbs/test/guaranteed.rb
rbs-3.4.0 lib/rbs/test/guaranteed.rb
rbs-3.4.0.pre.1 lib/rbs/test/guaranteed.rb