class Datafile::Bundle
todo/fix: turn into Datafile::Bundle.new
and Bundle#write
/save -why? why not?
Public Class Methods
new( path )
click to toggle source
# File lib/sportdb/formats/datafile.rb, line 15 def initialize( path ) @path = path @buf = String.new('') end
Public Instance Methods
<<(value)
click to toggle source
# File lib/sportdb/formats/datafile.rb, line 20 def <<(value) if value.is_a?( Array ) ## assume array of datafiles (file paths) datafiles = value datafiles.each do |datafile| text = Datafile.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 @buf << text @buf << "\n\n" end else ## assume string (e.g. header, comments, etc.) text = value @buf << text @buf << "\n\n" end end
Also aliased as: write
close()
click to toggle source
todo/fix/check: write only on close? or write on every write and use close for close?
# File lib/sportdb/formats/datafile.rb, line 39 def close File.open( @path, 'w:utf-8' ) do |f| f.write @buf end end