class Bio::FlatFileIndex::FileIDs

FileIDs class.

Internal use only.

Public Class Methods

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

Public Instance Methods

[](n) click to toggle source
Calls superclass method
# 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
[]=(n, data) click to toggle source
Calls superclass method
# 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
add(*arg) click to toggle source
# File lib/bio/io/flatfile/index.rb, line 602
def add(*arg)
  arg.each do |filename|
    self << FileID.new(filename)
  end
end
cache_all() click to toggle 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
check_all() click to toggle 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
Also aliased as: check
close()
Alias for: close_all
close_all() click to toggle source
# File lib/bio/io/flatfile/index.rb, line 668
def close_all
  self.each do |x|
    x.close
  end
  nil
end
Also aliased as: close
each() { |x| ... } click to toggle 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
each_with_index() { |x, i| ... } click to toggle 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
filenames() click to toggle 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
keys() click to toggle 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
recalc_all() click to toggle 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
Also aliased as: recalc