Class: Bio::FlatFileIndex::NameSpaces
- Defined in:
- lib/bio/io/flatfile/index.rb
Overview
namespaces
Internal use only.
Instance Method Summary collapse
- #close_all ⇒ Object (also: #close)
- #each_files ⇒ Object
- #each_names ⇒ Object
-
#initialize(dbname, nsclass, arg) ⇒ NameSpaces
constructor
A new instance of NameSpaces.
- #names ⇒ Object
- #search(key) ⇒ Object
- #search_names(key, *names) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(dbname, nsclass, arg) ⇒ NameSpaces
Returns a new instance of NameSpaces.
1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 |
# File 'lib/bio/io/flatfile/index.rb', line 1046 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
#close_all ⇒ Object Also known as: close
1076 1077 1078 |
# File 'lib/bio/io/flatfile/index.rb', line 1076 def close_all values.each { |x| x.file.close } end |
#each_files ⇒ Object
1066 1067 1068 1069 1070 |
# File 'lib/bio/io/flatfile/index.rb', line 1066 def each_files self.values.each do |x| yield x end end |
#each_names ⇒ Object
1060 1061 1062 1063 1064 |
# File 'lib/bio/io/flatfile/index.rb', line 1060 def each_names self.names.each do |x| yield x end end |
#names ⇒ Object
1072 1073 1074 |
# File 'lib/bio/io/flatfile/index.rb', line 1072 def names keys end |
#search(key) ⇒ Object
1081 1082 1083 1084 1085 1086 1087 1088 1089 |
# File 'lib/bio/io/flatfile/index.rb', line 1081 def search(key) r = [] values.each do |ns| r.concat ns.search(key) end r.sort! r.uniq! r end |
#search_names(key, *names) ⇒ Object
1091 1092 1093 1094 1095 1096 1097 1098 1099 |
# File 'lib/bio/io/flatfile/index.rb', line 1091 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 |
#to_s ⇒ Object
1101 1102 1103 |
# File 'lib/bio/io/flatfile/index.rb', line 1101 def to_s names.join("\t") end |