2 # = lib/evo/io/parser/basic_table_parser - BasicTableParser class
4 # Copyright:: Copyright (C) 2006-2007 Christian M. Zmasek
5 # License:: GNU Lesser General Public License (LGPL)
7 # $Id: basic_table_parser.rb,v 1.3 2007/09/28 03:12:10 cmzmasek Exp $
9 # last modified: 05/16/2007
13 class BasicTableParser
15 START_OF_COMMENT_LINE_CHAR = "#"
17 # raises ArgumentError
18 def BasicTableParser.parse( path, column_delimiter )
19 Util.check_file_for_readability( path )
20 table = BasicTable.new
22 File.open( path ) do | file |
23 while line = file.gets
24 if ( !Util.is_string_empty?( line ) &&
25 !line.slice( 0, 1 ).eql?( START_OF_COMMENT_LINE_CHAR ) )
26 values = line.split( column_delimiter )
28 values.each { | value |
29 table.set_value( row, col, value.strip! )
39 end # class BasicTableParser