Module: CutePrint
- Defined in:
- lib/cute_print/cute_print.rb,
lib/cute_print/mixin.rb,
lib/cute_print/values.rb,
lib/cute_print/labeler.rb,
lib/cute_print/printer.rb,
lib/cute_print/release.rb,
lib/cute_print/location.rb,
lib/cute_print/configure.rb,
lib/cute_print/formatter.rb,
lib/cute_print/stderr_out.rb,
lib/cute_print/term_width.rb,
lib/cute_print/ruby_parser.rb,
lib/cute_print/source_label.rb,
lib/cute_print/format/inspect.rb,
lib/cute_print/inline_labeler.rb,
lib/cute_print/location_label.rb,
lib/cute_print/ruby_generator.rb,
lib/cute_print/outline_labeler.rb,
lib/cute_print/ruby_parser/block.rb,
lib/cute_print/term_width/static.rb,
lib/cute_print/format/pretty_print.rb,
lib/cute_print/location_label/path.rb,
lib/cute_print/term_width/detected.rb,
lib/cute_print/finds_foreign_caller.rb,
lib/cute_print/ruby_parser/wraps_sexp.rb,
lib/cute_print/location_label/filename.rb,
lib/cute_print/ruby_parser/method_call.rb,
lib/cute_print/ruby_parser/parsed_code.rb
Overview
Like Kernel#p, only fancier. For example, this code:
require "cute_print"
q { 1 + 2 }
prints this to $stderr:
(1 + 2) is 3
Defined Under Namespace
Modules: FindsForeignCaller, Format, Mixin, Release Classes: Configure, Formatter, InlineLabeler, Labeler, Location, LocationLabel, OutlineLabeler, Printer, RubyGenerator, RubyParser, SourceLabel, StderrOut, TermWidth, Values
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Object
Configure the library.
-
.printer ⇒ Printer
private
The singleton printer.
-
.q(*args, &block) ⇒ Object
Inspect and write one or more objects.
-
.ql(*args, &block) ⇒ Object
Inspect and write one or more objects, with source location.
-
.qq(*args, &block) ⇒ Object
Pretty-print and write one or more objects.
-
.qql(*args, &block) ⇒ Object
Pretty-print and write one or more objects, with source location.
Class Method Details
.configure {|config| ... } ⇒ Object
Configure the library. For example:
CutePrint.configure do |c|
c.out = $stdout
end
21 22 23 |
# File 'lib/cute_print/cute_print.rb', line 21 def self.configure(&block) Configure.new(printer, &block) end |
.printer ⇒ Printer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the singleton printer.
27 28 29 |
# File 'lib/cute_print/cute_print.rb', line 27 def self.printer @printer ||= Printer.new end |
.q(*args, &block) ⇒ Object
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.
40 41 42 |
# File 'lib/cute_print/cute_print.rb', line 40 def self.q(*args, &block) printer.q(*args, &block) end |
.ql(*args, &block) ⇒ Object
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.
53 54 55 |
# File 'lib/cute_print/cute_print.rb', line 53 def self.ql(*args, &block) printer.ql(*args, &block) end |
.qq(*args, &block) ⇒ Object
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.
66 67 68 |
# File 'lib/cute_print/cute_print.rb', line 66 def self.qq(*args, &block) printer.qq(*args, &block) end |
.qql(*args, &block) ⇒ Object
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.
79 80 81 |
# File 'lib/cute_print/cute_print.rb', line 79 def self.qql(*args, &block) printer.qql(*args, &block) end |