module Datafile

Public Class Methods

read( path ) click to toggle source
# File lib/sportdb/formats/datafile.rb, line 6
def self.read( path )   ## todo/check: use as a shortcut helper - why? why not?
   ## note: always assume utf-8 for now!!!
   File.open( path, 'r:utf-8') {|f| f.read }
end
write_bundle( path, datafiles:, header: nil ) click to toggle source
# File lib/sportdb/formats/datafile.rb, line 47
def self.write_bundle( path, datafiles:, header: nil )
  bundle = Bundle.new( path )
  bundle.write( header )   if header
  datafiles.each do |datafile|
    text = read( datafile )
    ## todo/fix/check:  move  sub __END__ to Datafile.read and turn it always on  -  why? why not?
    text = text.sub( /__END__.*/m, '' )    ## note: add/allow support for __END__; use m-multiline flag
    bundle.write( text )
  end
  bundle.close
end