Module: Datafile
- Defined in:
- lib/sportdb/formats/datafile.rb,
lib/sportdb/formats/datafile_package.rb
Overview
note: keep Datafile in its own top-level module/namespace for now - why? why not?
Defined Under Namespace
Classes: Bundle, DirPackage, Package, ZipPackage
Class Method Summary collapse
-
.read(path) ⇒ Object
todo/check: use as a shortcut helper - why? why not?.
- .write_bundle(path, datafiles:, header: nil) ⇒ Object
Class Method Details
.read(path) ⇒ Object
todo/check: use as a shortcut helper - why? why not?
6 7 8 9 |
# 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) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# 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 |