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.



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

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)



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

def entry
  @entry
end

#entry_ended_posObject

(end position of the entry) + 1



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

def entry_ended_pos
  @entry_ended_pos
end

#entry_pos_flagObject

a flag to write down entry start and end positions



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

def entry_pos_flag
  @entry_pos_flag
end

#entry_start_posObject

start position of the entry



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

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.



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

def parsed_entry
  @parsed_entry
end

Instance Method Details

#get_entryObject

Gets entry as a string. (String)

Raises:

  • (NotImplementedError)


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

def get_entry
  raise NotImplementedError
end

#get_parsed_entryObject

Gets entry as a data class’s object



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

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



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

def rewind
  @stream.rewind
end

#skip_leaderObject

skips leader of the entry.

Raises:

  • (NotImplementedError)


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

def skip_leader
  raise NotImplementedError
end