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.
-
#term_width ⇒ Object
The terminal width.
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)
44 45 46 47 |
# File 'lib/cute_print/printer.rb', line 44 def initialize(attrs = {}) set_defaults attrs.each { |name, value| send "#{name}=", value } end |
Instance Attribute Details
#location_format ⇒ String
The location format. Defaults to :filename
One of:
-
:filename
-
:path
21 22 23 |
# File 'lib/cute_print/printer.rb', line 21 def location_format @location_format end |
#out ⇒ #print
The object to write to. Defaults to $stderr.
12 13 14 |
# File 'lib/cute_print/printer.rb', line 12 def out @out end |
#term_width ⇒ Object
The terminal width. May be an integer, or :detect to cause the terminal width to be determined automatically. Defaults to :detect
30 31 32 |
# File 'lib/cute_print/printer.rb', line 30 def term_width @term_width.visible end |
Instance Method Details
#q(*values, &block) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/cute_print/printer.rb', line 57 def q(*values, &block) formatter = make_formatter(__method__, values, block) formatter.inspect formatter.write nil end |
#ql(*values, &block) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/cute_print/printer.rb', line 65 def ql(*values, &block) formatter = make_formatter(__method__, values, block) formatter.inspect formatter.with_location @location_format formatter.write nil end |
#qq(*values, &block) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/cute_print/printer.rb', line 74 def qq(*values, &block) formatter = make_formatter(__method__, values, block) formatter.pretty_print formatter.write nil end |
#qql(*values, &block) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/cute_print/printer.rb', line 82 def qql(*values, &block) formatter = make_formatter(__method__, values, block) formatter.pretty_print formatter.with_location @location_format formatter.write nil end |