Sha256: e5136c068decb7d8cadc4d34ab767a3c95e90773322c3a53a7edf31470b41647

Contents?: true

Size: 709 Bytes

Versions: 13

Compression:

Stored size: 709 Bytes

Contents

# frozen_string_literal: true

class Object
  def pretty_debug(options = {})
    print_debug_title(options)

    STDERR.write(pretty_inspect)

    self
  end

  def print_debug(options = {})
    print_debug_title(options)
    STDERR.write(to_debug + "\n")

    self
  end

  def print_debug_title(title)
    if title.is_a?(::Hash)
      return unless title[:title]

      title = title[:title]
    end
    char = '='
    STDERR.write(char * (4 + title.length) + "\n")
    STDERR.write("#{char} #{title} #{char}\n")
    STDERR.write(char * (4 + title.length) + "\n")
  end

  def to_debug
    "|#{::Object.instance_method(:to_s).bind(self).call}|#{self}|"
  end

  def raise_debug
    raise to_debug
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
eac_tools-0.28.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb
eac_tools-0.27.2 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb
eac_ruby_utils-0.102.1 lib/eac_ruby_utils/patches/object/debug.rb
eac_tools-0.27.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb
eac_tools-0.27.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb
eac_tools-0.26.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb
eac_ruby_utils-0.102.0 lib/eac_ruby_utils/patches/object/debug.rb
eac_tools-0.25.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb
eac_ruby_utils-0.101.0 lib/eac_ruby_utils/patches/object/debug.rb
eac_tools-0.25.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb
eac_tools-0.24.1 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb
eac_ruby_utils-0.100.0 lib/eac_ruby_utils/patches/object/debug.rb
eac_tools-0.24.0 sub/eac_ruby_utils/lib/eac_ruby_utils/patches/object/debug.rb