Class: Bio::FlatFile::Splitter::Template

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

Overview

This is a template of splitter.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, bstream) ⇒ Template

Creates a new splitter.



31
32
33
34
35
# File 'lib/bio/io/flatfile/splitter.rb', line 31

def initialize(klass, bstream)
  @dbclass = klass
  @stream = bstream
  @entry_pos_flag = nil
end

Instance Attribute Details

#entryObject

the last entry string read from the stream (String)



64
65
66
# File 'lib/bio/io/flatfile/splitter.rb', line 64

def entry
  @entry
end

#entry_ended_posObject

(end position of the entry) + 1



78
79
80
# File 'lib/bio/io/flatfile/splitter.rb', line 78

def entry_ended_pos
  @entry_ended_pos
end

#entry_pos_flagObject

a flag to write down entry start and end positions



72
73
74
# File 'lib/bio/io/flatfile/splitter.rb', line 72

def entry_pos_flag
  @entry_pos_flag
end

#entry_start_posObject

start position of the entry



75
76
77
# File 'lib/bio/io/flatfile/splitter.rb', line 75

def entry_start_pos
  @entry_start_pos
end

#parsed_entryObject

The last parsed entry read from the stream (entry data class). Note that it is valid only after get_parsed_entry is called, and the get_entry may not affect the parsed_entry attribute.



69
70
71
# File 'lib/bio/io/flatfile/splitter.rb', line 69

def parsed_entry
  @parsed_entry
end

Instance Method Details

#get_entryObject

Gets entry as a string. (String)

Raises:

  • (NotImplementedError)


48
49
50
# File 'lib/bio/io/flatfile/splitter.rb', line 48

def get_entry
  raise NotImplementedError
end

#get_parsed_entryObject

Gets entry as a data class’s object



53
54
55
56
57
58
59
60
61
# File 'lib/bio/io/flatfile/splitter.rb', line 53

def get_parsed_entry
  ent = get_entry
  if ent then
    self.parsed_entry = dbclass.new(ent)
  else
    self.parsed_entry = ent
  end
  parsed_entry
end

#rewindObject

rewind the stream



43
44
45
# File 'lib/bio/io/flatfile/splitter.rb', line 43

def rewind
  @stream.rewind
end

#skip_leaderObject

skips leader of the entry.

Raises:

  • (NotImplementedError)


38
39
40
# File 'lib/bio/io/flatfile/splitter.rb', line 38

def skip_leader
  raise NotImplementedError
end