Method: TkMultiListFrame#insert

Defined in:
sample/tkmultilistframe.rb

#insert(idx, *lines) ⇒ Object



489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'sample/tkmultilistframe.rb', line 489

def insert(idx, *lines)
  lbox_ins = []
  (0..@lbox_list.size).each{lbox_ins << []}

  lines.each{|line|
    if line.kind_of? Hash
      array = []
      @name_index.each_pair{|label, indices|
        if indices.size == 1
          array[indices[0]] = line[label]
        else
          if line[label].kind_of? Array
            indices.each_with_index{|index, num| 
              array[index] = line[label][num]
            }
          else
            array[indices[0]] = line[label]
          end
        end
      }
      line = array
    end

    @name_index.each_pair{|label, indices|
      if indices.size == 1
        lbox_ins[indices[0]] << line[indices[0]]
      else
        indices.each{|index| lbox_ins[index] << line[index]}
      end
    }
  }   

  @lbox_list.each_with_index{|lbox, index| 
    lbox.insert(idx, *lbox_ins[index]) if lbox_ins[index]
  }
end