Sha256: 1f26c43f694f5d91f322092be5879e922838b3749b397126397560b430da0c2e

Contents?: true

Size: 557 Bytes

Versions: 1

Compression:

Stored size: 557 Bytes

Contents

# frozen_string_literal: true

def print_debug(thing = nil, backtrace_offset: 0, **keywords)
  backtrace_line = caller[backtrace_offset].split(':')[0..1].join(':')
  thing = keywords if thing.eql?(nil) && keywords.any?
  thing = thing.inspect unless thing.is_a?(String)
  color = PDRuby.color_for(backtrace_line)

  puts(
    (
      'PD: ' + thing
    ).colorize(color) +
      ' @ ' + backtrace_line.to_s.colorize(color)
  )
  puts "\n"
  thing
end

def pd(thing = nil, options = {})
  options[:backtrace_offset] ||= 1
  print_debug(thing, **options)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pd_ruby-0.2.3 lib/pd_ruby/helper_methods.rb