Sha256: 48064501f3e893cc7b4d2169deaa584c4835920ceeb1592470b42a08c482dbc9

Contents?: true

Size: 555 Bytes

Versions: 2

Compression:

Stored size: 555 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

2 entries across 2 versions & 1 rubygems

Version Path
pd_ruby-0.2.2 lib/pd_ruby/helper_methods.rb
pd_ruby-0.2.0 lib/pd_ruby/helper_methods.rb