Sha256: 0ebe0c4e6b8ae41f471c384587abdd98def6e7cbda2730a07fedfd2bc9bcc313

Contents?: true

Size: 425 Bytes

Versions: 6

Compression:

Stored size: 425 Bytes

Contents

require 'internal/node'
require 'internal/node/as_expression'
require 'internal/node/pp'

module Internal
  # Print an expression and its result, e.g.:
  #
  #   printdebug { 1 + 1 }
  #
  # will print:
  #
  #   test.rb:42: 1 + 1 => 2
  #
  def printdebug(&block)
    puts "#{caller[0]}: #{block.body.as_expression} => #{block.call}"
  end
end

if __FILE__ == $0 then
  include Internal
  a = 41
  printdebug { a + 1 }
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-internal-0.8.5 lib/internal/debug.rb
ruby-internal-0.8.4 lib/internal/debug.rb
ruby-internal-0.8.3 lib/internal/debug.rb
ruby-internal-0.8.2 lib/internal/debug.rb
ruby-internal-0.8.1 lib/internal/debug.rb
ruby-internal-0.8.0 lib/internal/debug.rb