Sha256: 447ba9305f6b1179c3de6c9e489256382522290edcf93c859c4c7c4de3598a59
Contents?: true
Size: 1.03 KB
Versions: 23
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true require 'eac_ruby_utils/patches/object/if_present' require 'pp' class Object def compact_debug(*methods_names) methods_names.each do |method_name| send(method_name).print_debug(label: method_name) end end def pretty_debug(options = {}) print_debug_options(options) STDERR.write(pretty_inspect) self end def print_debug(options = {}) print_debug_options(options) STDERR.write(to_debug + "\n") self end def print_debug_label(label) STDERR.write("#{label}: ") end def print_debug_options(options) options[:title].if_present { |v| print_debug_title(v) } options[:label].if_present { |v| print_debug_label(v) } end def print_debug_title(title) 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
23 entries across 23 versions & 2 rubygems