Class: Bio::SOFT::Table::Row

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(n, header_object = nil) ⇒ Row

Returns a new instance of Row.



214
215
216
217
# File 'lib/bio/db/soft.rb', line 214

def initialize( n, header_object=nil )
  @header_object = header_object
  super(n)
end

Instance Attribute Details

#header_objectObject

Returns the value of attribute header_object.



212
213
214
# File 'lib/bio/db/soft.rb', line 212

def header_object
  @header_object
end

Instance Method Details

#[](x) ⇒ Object



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/bio/db/soft.rb', line 219

def [](x)
  if x.kind_of?( Fixnum )
    super(x)
  else
    begin
      x = x.to_s.downcase.to_sym
      z = @header_object.column_index[x]
      unless z.kind_of?( Fixnum )
        raise IndexError, "#{x.inspect} is not a valid index.  Contents of @header_object.column_index: #{@header_object.column_index.inspect}"
      end
      self[ z ]
    rescue NoMethodError
      unless @header_object
        $stderr.puts "Table::Row @header_object undefined!"
      end
      raise
    end
  end
end