Class: Bio::FlatFileIndex::Flat_1::Record

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

Overview

Record class.

Internal use only.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, size = nil) ⇒ Record



696
697
698
699
700
701
702
703
# File 'lib/bio/io/flatfile/index.rb', line 696

def initialize(str, size = nil)
  a = str.split("\t")
  a.each { |x| x.to_s.gsub!(/[\000 ]+\z/, '') }
  @key = a.shift.to_s
  @val = a
  @size = (size or str.length)
  #DEBUG.print "key=#{@key.inspect},val=#{@val.inspect},size=#{@size}\n"
end

Instance Attribute Details

#keyObject (readonly)

DEBUG.print “key=#Bio::FlatFileIndex::Flat_1::Record.@key@key.inspect,val=#Bio::FlatFileIndex::Flat_1::Record.@val@val.inspect,size=#@sizen”



704
705
706
# File 'lib/bio/io/flatfile/index.rb', line 704

def key
  @key
end

#sizeObject (readonly)

DEBUG.print “key=#Bio::FlatFileIndex::Flat_1::Record.@key@key.inspect,val=#Bio::FlatFileIndex::Flat_1::Record.@val@val.inspect,size=#@sizen”



704
705
706
# File 'lib/bio/io/flatfile/index.rb', line 704

def size
  @size
end

#valObject (readonly)

DEBUG.print “key=#Bio::FlatFileIndex::Flat_1::Record.@key@key.inspect,val=#Bio::FlatFileIndex::Flat_1::Record.@val@val.inspect,size=#@sizen”



704
705
706
# File 'lib/bio/io/flatfile/index.rb', line 704

def val
  @val
end

Class Method Details

.create(size, key, val) ⇒ Object



714
715
716
# File 'lib/bio/io/flatfile/index.rb', line 714

def self.create(size, key, val)
  self.new(self.to_string(size, key, val))
end

.to_string(size, key, val) ⇒ Object



710
711
712
# File 'lib/bio/io/flatfile/index.rb', line 710

def self.to_string(size, key, val)
  sprintf("%-*s", size, key + "\t" + val.join("\t"))
end

Instance Method Details

#==(x) ⇒ Object



718
719
720
# File 'lib/bio/io/flatfile/index.rb', line 718

def ==(x)
  self.to_s == x.to_s
end

#to_sObject



706
707
708
# File 'lib/bio/io/flatfile/index.rb', line 706

def to_s
  self.class.to_string(@size, @key, @val)
end