File: nice_inspect.rb

package info (click to toggle)
ruby-websocket 1.2.9-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 464 kB
  • sloc: ruby: 2,669; makefile: 4
file content (12 lines) | stat: -rw-r--r-- 338 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
# frozen_string_literal: true

module WebSocket
  module NiceInspect
    # Recreate inspect as #to_s will be overwritten
    def inspect
      vars = instance_variables.map { |v| "#{v}=#{instance_variable_get(v).inspect}" }.join(', ')
      insp = Kernel.format("#{self.class}:0x%08x", __id__)
      "<#{insp} #{vars}>"
    end
  end
end