module CutePrint

Like Kernel#p, only fancier. For example, this code:

require "cute_print"
q { 1 + 2 }

prints this to $stderr:

(1 + 2) is 3

Public Class Methods

configure(&block) click to toggle source

Configure the library. For example:

CutePrint.configure do |c|
  c.out = $stdout
end

@yieldparam config [Configure]

# File lib/cute_print/cute_print.rb, line 21
def self.configure(&block)
  Configure.new(printer, &block)
end
printer() click to toggle source

@return [Printer] the singleton printer @api private

# File lib/cute_print/cute_print.rb, line 27
def self.printer
  @printer ||= Printer.new
end
q(*args, &block) click to toggle source

Inspect and write one or more objects.

If called without a block, prints the inspected arguments, one on a line.

If called with a block, prints the source code of the block and the inspected result of the block.

@return nil

# File lib/cute_print/cute_print.rb, line 40
def self.q(*args, &block)
  printer.q(*args, &block)
end
ql(*args, &block) click to toggle source

Inspect and write one or more objects, with source location.

If called without a block, prints the inspected arguments, one on a line.

If called with a block, prints the source code of the block and the inspected result of the block.

@return nil

# File lib/cute_print/cute_print.rb, line 53
def self.ql(*args, &block)
  printer.ql(*args, &block)
end
qq(*args, &block) click to toggle source

Pretty-print and write one or more objects.

If called without a block, pretty-prints the pretty-printed arguments, one on a line.

If called with a block, prints the source code of the block and pretty-prints the result of the block.

@return nil

# File lib/cute_print/cute_print.rb, line 66
def self.qq(*args, &block)
  printer.qq(*args, &block)
end
qql(*args, &block) click to toggle source

Pretty-print and write one or more objects, with source location.

If called without a block, pretty-prints the arguments, one on a line.

If called with a block, prints the source code of the block and pretty-prints the result of the block.

@return nil

# File lib/cute_print/cute_print.rb, line 79
def self.qql(*args, &block)
  printer.qql(*args, &block)
end