Method: Bio::Nexus::NexusMatrix#set_value

Defined in:
lib/bio/db/nexus.rb

#set_value(row, col, value) ⇒ Object

Sets the value at row ‘row’ and column ‘col’ to ‘value’.


Arguments:

  • (required) row: Integer

  • (required) col: Integer

  • (required) value: Object



1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
# File 'lib/bio/db/nexus.rb', line 1598

def set_value( row, col, value ) 
  if ( ( row < 0 ) || ( col < 0 ) )
      raise( NexusTableError, "attempt to use negative values for row or column" )
  end
  if ( row > get_max_row() ) 
    set_max_row( row )
  end
  if ( col > get_max_col() ) 
    set_max_col( col )
  end
  row_map = nil
  if ( @rows.has_key?( row ) ) 
    row_map = @rows[ row ]
  else 
    row_map = Hash.new
    @rows[ row ] = row_map
  end
  row_map[ col ] = value
end