Class: Tb::FileHeaderEnumerator::HBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/tb/fileenumerator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ HBuilder

Returns a new instance of HBuilder.



305
306
307
308
309
310
# File 'lib/tb/fileenumerator.rb', line 305

def initialize(klass)
  @klass = klass
  @tempfile = Tempfile.new("tb")
  @tempfile.binmode
  @header = []
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



311
312
313
# File 'lib/tb/fileenumerator.rb', line 311

def header
  @header
end

Instance Method Details

#gen(*objs) ⇒ Object



313
314
315
316
# File 'lib/tb/fileenumerator.rb', line 313

def gen(*objs)
  @header |= objs[0].keys
  Marshal.dump(objs, @tempfile)
end

#newObject



318
319
320
321
322
323
324
# File 'lib/tb/fileenumerator.rb', line 318

def new
  @tempfile.close
  @klass.new(
    @header,
    lambda { open(@tempfile.path, "rb") },
    lambda { @tempfile.close(true) })
end