Class: Bio::FlatFileIndex::NameSpaces

Inherits:
Hash show all
Defined in:
lib/bio/io/flatfile/index.rb

Overview

namespaces

Internal use only.

Instance Method Summary (collapse)

Constructor Details

- (NameSpaces) initialize(dbname, nsclass, arg)



1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
# File 'lib/bio/io/flatfile/index.rb', line 1056

def initialize(dbname, nsclass, arg)
  @dbname = dbname
  @nsclass = nsclass
  if arg.is_a?(String) then
    a = arg.split("\t")
  else
    a = arg
  end
  a.each do |x|
    self[x] = @nsclass.new(@dbname, x)
  end
  self
end

Instance Method Details

- (Object) close_all Also known as: close



1086
1087
1088
# File 'lib/bio/io/flatfile/index.rb', line 1086

def close_all
  values.each { |x| x.file.close }
end

- (Object) each_files



1076
1077
1078
1079
1080
# File 'lib/bio/io/flatfile/index.rb', line 1076

def each_files
  self.values.each do |x|
    yield x
  end
end

- (Object) each_names



1070
1071
1072
1073
1074
# File 'lib/bio/io/flatfile/index.rb', line 1070

def each_names
  self.names.each do |x|
    yield x
  end
end

- (Object) names



1082
1083
1084
# File 'lib/bio/io/flatfile/index.rb', line 1082

def names
  keys
end

- (Object) search(key)



1091
1092
1093
1094
1095
1096
1097
1098
1099
# File 'lib/bio/io/flatfile/index.rb', line 1091

def search(key)
  r = []
  values.each do |ns|
    r.concat ns.search(key)
  end
  r.sort!
  r.uniq!
  r
end

- (Object) search_names(key, *names)



1101
1102
1103
1104
1105
1106
1107
1108
1109
# File 'lib/bio/io/flatfile/index.rb', line 1101

def search_names(key, *names)
  r = []
  names.each do |x|
    ns = self[x]
    raise "undefined namespace #{x.inspect}" unless ns
    r.concat ns.search(key)
  end
  r
end

- (Object) to_s



1111
1112
1113
# File 'lib/bio/io/flatfile/index.rb', line 1111

def to_s
  names.join("\t")
end