Class: Array

Inherits:
Object show all
Defined in:
lib/colorful_inspect.rb

Instance Method Summary collapse

Instance Method Details

#colorless_pretty_printObject



98
# File 'lib/colorful_inspect.rb', line 98

alias colorless_pretty_print pretty_print

#pretty_print(q) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/colorful_inspect.rb', line 100

def pretty_print(q)
  return q.text("[]") if empty?

  ColorfulInspect.group(q, "[", "]") do
    index_width = (size - 1).to_s.size

    each_with_index do |elem, n|
      ColorfulInspect.break q
      q.text "[#{n.to_s.rjust(index_width)}] "
      q.pp elem
      q.text "," if n != size - 1
    end
  end
end