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

- (Table) initialize

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

- (Object) header

Returns the value of attribute header



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

def header
  @header
end

- (Object) header_description

Returns the value of attribute header_description



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

def header_description
  @header_description
end

- (Object) rows

Returns the value of attribute rows



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

def rows
  @rows
end

Instance Method Details

- (Object) add_header(line)



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

- (Object) add_header_or_row(line)



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

- (Object) add_row(line)



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

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