Class: Bio::SOFT::Table

Inherits:
Object show all
Defined in:
lib/bio/db/soft.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Header, Row

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTable

Returns a new instance of Table.



240
241
242
243
244
# File 'lib/bio/db/soft.rb', line 240

def initialize()
  @header_description = {}
  @header = Header.new
  @rows = []
end

Instance Attribute Details

#headerObject

Returns the value of attribute header.



198
199
200
# File 'lib/bio/db/soft.rb', line 198

def header
  @header
end

#header_descriptionObject

Returns the value of attribute header_description.



199
200
201
# File 'lib/bio/db/soft.rb', line 199

def header_description
  @header_description
end

#rowsObject

Returns the value of attribute rows.



200
201
202
# File 'lib/bio/db/soft.rb', line 200

def rows
  @rows
end

Instance Method Details

#add_header(line) ⇒ Object



246
247
248
249
250
251
252
# File 'lib/bio/db/soft.rb', line 246

def add_header( line )
  raise "Can only define one header" unless @header.empty?      
  @header = @header.concat( parse_row( line ) )  # beware of clobbering this into an Array
  @header.each_with_index do |key, i|
    @header.column_index[key.downcase.to_sym] = i
  end
end

#add_header_or_row(line) ⇒ Object



258
259
260
# File 'lib/bio/db/soft.rb', line 258

def add_header_or_row( line )
  @header.empty? ? add_header( line ) : add_row( line )        
end

#add_row(line) ⇒ Object



254
255
256
# File 'lib/bio/db/soft.rb', line 254

def add_row( line )
  @rows << Row.new( parse_row( line ), @header )
end