Class | Bio::FlatFileIndex::FileIDs
In: | lib/bio/io/flatfile/index.rb
Parent: | Array

FileIDs class.

Internal use only.

### Methods

[] []= add cache_all check check_all close close_all each each_with_index filenames keys new recalc recalc_all

### Public Class methods

new(prefix, hash)

[Source]

         # File lib/bio/io/flatfile/index.rb, line 572
    572:       def initialize(prefix, hash)
    573:         @hash = hash
    574:         @prefix = prefix
    575:       end

### Public Instance methods

[](n)

[Source]

         # File lib/bio/io/flatfile/index.rb, line 577
    577:       def [](n)
    578:         r = super(n)
    579:         if r then
    580:           r
    581:         else
    582:           data = @hash["#{@prefix}#{n}"]
    583:           if data then
    584:             self[n] = data
    585:           end
    586:           super(n)
    587:         end
    588:       end

[]=(n, data)

[Source]

         # File lib/bio/io/flatfile/index.rb, line 590
    590:       def []=(n, data)
    591:         if data.is_a?(FileID) then
    592:           super(n, data)
    593:         elsif data then
    594:           super(n, FileID.new_from_string(data))
    595:         else
    596:           # data is nil
    597:           super(n, nil)
    598:         end
    599:         self[n]
    600:       end

add(*arg)

[Source]

         # File lib/bio/io/flatfile/index.rb, line 602
    602:       def add(*arg)
    603:         arg.each do |filename|
    604:           self << FileID.new(filename)
    605:         end
    606:       end

cache_all()

[Source]

         # File lib/bio/io/flatfile/index.rb, line 608
    608:       def cache_all
    609:         a = @hash.keys.collect do |k|
    610:           if k =~ /\A#{Regexp.escape(@prefix)}(\d+)/ then
    611:             $1.to_i
    612:           else
    613:             nil
    614:           end
    615:         end
    616:         a.compact!
    617:         a.each do |i|
    618:           self[i]
    619:         end
    620:         a
    621:       end

check()

Alias for check_all

check_all()

[Source]

         # File lib/bio/io/flatfile/index.rb, line 657
    657:       def check_all
    658:         self.cache_all
    659:         r = true
    660:         self.each do |x|
    661:           r = x.check
    662:           break unless r
    663:         end
    664:         r
    665:       end

close()

Alias for close_all

close_all()

[Source]

         # File lib/bio/io/flatfile/index.rb, line 668
    668:       def close_all
    669:         self.each do |x|
    670:           x.close
    671:         end
    672:         nil
    673:       end

each() {|x| ...}

[Source]

         # File lib/bio/io/flatfile/index.rb, line 623
    623:       def each
    624:         (0...self.size).each do |i|
    625:           x = self[i]
    626:           yield(x) if x
    627:         end
    628:         self
    629:       end

each_with_index() {|x, i| ...}

[Source]

         # File lib/bio/io/flatfile/index.rb, line 631
    631:       def each_with_index
    632:         (0...self.size).each do |i|
    633:           x = self[i]
    634:           yield(x, i) if x
    635:         end
    636:         self
    637:       end

filenames()

[Source]

         # File lib/bio/io/flatfile/index.rb, line 648
    648:       def filenames
    649:         self.cache_all
    650:         a = []
    651:         self.each do |x|
    652:           a << x.filename
    653:         end
    654:         a
    655:       end

keys()

[Source]

         # File lib/bio/io/flatfile/index.rb, line 639
    639:       def keys
    640:         self.cache_all
    641:         a = []
    642:         (0...self.size).each do |i|
    643:           a << i if self[i]
    644:         end
    645:         a
    646:       end

recalc()

Alias for recalc_all

recalc_all()

[Source]

         # File lib/bio/io/flatfile/index.rb, line 676
    676:       def recalc_all
    677:         self.cache_all
    678:         self.each do |x|
    679:           x.recalc
    680:         end
    681:         true
    682:       end

[Validate]