Class Bio::FlatFileIndex::FileIDs
In: lib/bio/io/flatfile/index.rb  (CVS)
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

[Source]

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

Public Instance methods

[Source]

# File lib/bio/io/flatfile/index.rb, line 577
      def [](n)
        r = super(n)
        if r then
          r
        else
          data = @hash["#{@prefix}#{n}"]
          if data then
            self[n] = data
          end
          super(n)
        end
      end

[Source]

# File lib/bio/io/flatfile/index.rb, line 590
      def []=(n, data)
        if data.is_a?(FileID) then
          super(n, data)
        elsif data then
          super(n, FileID.new_from_string(data))
        else
          # data is nil
          super(n, nil)
        end
        self[n]
      end

[Source]

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

[Source]

# File lib/bio/io/flatfile/index.rb, line 608
      def cache_all
        a = @hash.keys.collect do |k|
          if k =~ /\A#{Regexp.escape(@prefix)}(\d+)/ then
            $1.to_i
          else
            nil
          end
        end
        a.compact!
        a.each do |i|
          self[i]
        end
        a
      end
check()

Alias for check_all

[Source]

# File lib/bio/io/flatfile/index.rb, line 657
      def check_all
        self.cache_all
        r = true
        self.each do |x|
          r = x.check
          break unless r
        end
        r
      end
close()

Alias for close_all

[Source]

# File lib/bio/io/flatfile/index.rb, line 668
      def close_all
        self.each do |x|
          x.close
        end
        nil
      end

[Source]

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

[Source]

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

[Source]

# File lib/bio/io/flatfile/index.rb, line 648
      def filenames
        self.cache_all
        a = []
        self.each do |x|
          a << x.filename
        end
        a
      end

[Source]

# File lib/bio/io/flatfile/index.rb, line 639
      def keys
        self.cache_all
        a = []
        (0...self.size).each do |i|
          a << i if self[i]
        end
        a
      end
recalc()

Alias for recalc_all

[Source]

# File lib/bio/io/flatfile/index.rb, line 676
      def recalc_all
        self.cache_all
        self.each do |x|
          x.recalc
        end
        true
      end

[Validate]