Sha256: f9126a605da73a1f1f090e5181cc3b0ace93cfefa0afa83c127577b8e7a29523
Contents?: true
Size: 1.86 KB
Versions: 3
Compression:
Stored size: 1.86 KB
Contents
require_relative "formatter" require_relative "stderr_out" module CutePrint class Printer include FindsForeignCaller # The object to write to. Defaults to $stderr. # @return [#print] attr_accessor :out # The location format. # # One of: # * :filename # * :path # # @return [String] attr_accessor :location_format # Create an instance. If attributes are supplied, they override # the defaults. For example: # # CutePrint.new(:out => $stdout) # # @api private def initialize(attrs = {}) set_defaults attrs.each { |name, value| send "#{name}=", value } end # Set all attributes to their defaults. def set_defaults @out = StderrOut.new @location_format = :filename end # @see CutePrint.q def q(*values, &block) formatter = Formatter.new( method: __method__, out: @out, block: block, values: values ) formatter.inspect formatter.write nil end # @see CutePrint.ql def ql(*values, &block) formatter = Formatter.new( method: __method__, out: @out, block: block, values: values) formatter.inspect formatter.with_location @location_format formatter.write nil end # @see CutePrint.qq def qq(*values, &block) formatter = Formatter.new( method: __method__, out: @out, block: block, values: values) formatter.pretty_print formatter.write nil end # @see CutePrint.qql def qql(*values, &block) formatter = Formatter.new( method: __method__, out: @out, block: block, values: values) formatter.pretty_print formatter.with_location @location_format formatter.write nil end private end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cute_print-1.0.1 | lib/cute_print/printer.rb |
cute_print-1.0.0 | lib/cute_print/printer.rb |
cute_print-0.4.0 | lib/cute_print/printer.rb |