Sha256: 03d739b768100f104626a4d97e62f112f57b3c05a6deea83b4e741b9831bf1b0
Contents?: true
Size: 1.75 KB
Versions: 6
Compression:
Stored size: 1.75 KB
Contents
# text.rb : A simple backend to deal with basic text files. # Copyright (C) 2006 Vincent Fourmond # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA require 'Dobjects/Dvector' require 'Dobjects/Function' # For separated sets require 'stringio' module CTioga2 Version::register_svn_info('$Revision$', '$Date$') module Data module Backends class DirectBackend < Backend include Dobjects describe 'direct', 'Direct format', <<EOD A backend where one enters data points directly on the command line or in the command file EOD def initialize @separator = /\s+/ @line_separator = /[;,]/ super() end protected # This is called by the architecture to get the data. It # splits the set name into filename@cols, reads the file if # necessary and calls get_data def query_dataset(set) str = set.gsub(@line_separator, "\n") io = StringIO.new(str) cols = Dvector::fancy_read(io, nil) return Dataset.new("direct", cols) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems