module InspectArray

Public Instance Methods

scan(a, i=0) click to toggle source
# File lib/dom_render.rb, line 9
def scan(a, i=0)
  
  if a.first.is_a? Symbol
    
      puts a.inspect    
      
  else
    
    puts ('  ' * i) + '['

    a.each.with_index do |row, j|

      if row.is_a? String or row.is_a? Symbol then
        print ('  ' * (i+1)) + row.inspect
        print ',' unless a.length - 1 == j
        puts
      elsif row.first.is_a? Symbol or row.first.is_a? String
        puts ('  ' * (i+1)) + '['
        puts ('  ' * (i+2)) + row.inspect[1..-2]
        print ('  ' * (i+1)) + ']'
        print ',' unless a.length - 1 == j
        puts
      else
        scan(row,i+1)
        print ',' unless a.length - 1 == j
        puts
      end
    end

    print indent = ('  ' * i) + ']'
  end
end