Class: CutePrint::Printer
- Includes:
- FindsForeignCaller
- Defined in:
- lib/cute_print/printer.rb
Instance Attribute Summary collapse
-
#location_format ⇒ String
The location format.
-
#out ⇒ #print
The object to write to.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Printer
constructor
private
Create an instance.
- #q(*values, &block) ⇒ Object
- #ql(*values, &block) ⇒ Object
- #qq(*values, &block) ⇒ Object
- #qql(*values, &block) ⇒ Object
-
#set_defaults ⇒ Object
Set all attributes to their defaults.
Methods included from FindsForeignCaller
#lib_path, #nearest_foreign_caller
Constructor Details
#initialize(attrs = {}) ⇒ 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.
Create an instance. If attributes are supplied, they override the defaults. For example:
CutePrint.new(:out => $stdout)
28 29 30 31 |
# File 'lib/cute_print/printer.rb', line 28 def initialize(attrs = {}) set_defaults attrs.each { |name, value| send "#{name}=", value } end |
Instance Attribute Details
#location_format ⇒ String
The location format.
One of:
- :filename
- :path
20 21 22 |
# File 'lib/cute_print/printer.rb', line 20 def location_format @location_format end |
#out ⇒ #print
The object to write to. Defaults to $stderr.
11 12 13 |
# File 'lib/cute_print/printer.rb', line 11 def out @out end |
Instance Method Details
#q(*values, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cute_print/printer.rb', line 40 def q(*values, &block) formatter = Formatter.new( method: __method__, out: @out, block: block, values: values ) formatter.inspect formatter.write nil end |
#ql(*values, &block) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cute_print/printer.rb', line 53 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 |
#qq(*values, &block) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cute_print/printer.rb', line 66 def qq(*values, &block) formatter = Formatter.new( method: __method__, out: @out, block: block, values: values) formatter.pretty_print formatter.write nil end |
#qql(*values, &block) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/cute_print/printer.rb', line 78 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 |