Class: CutePrint::Printer

Inherits:
Object show all
Includes:
FindsForeignCaller
Defined in:
lib/cute_print/printer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_formatString

The location format.

One of:

  • :filename
  • :path

Returns:

  • (String)


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.

Returns:

  • (#print)


11
12
13
# File 'lib/cute_print/printer.rb', line 11

def out
  @out
end

Instance Method Details

#q(*values, &block) ⇒ Object

See Also:



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

See Also:



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

See Also:



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

See Also:



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

#set_defaultsObject

Set all attributes to their defaults.



34
35
36
37
# File 'lib/cute_print/printer.rb', line 34

def set_defaults
  @out = StderrOut.new
  @location_format = :filename
end