Class: Tb::FileEnumerator::Builder

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

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Builder

Returns a new instance of Builder.



54
55
56
57
58
# File 'lib/tb/fileenumerator.rb', line 54

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

Instance Method Details

#gen(*objs) ⇒ Object



60
61
62
# File 'lib/tb/fileenumerator.rb', line 60

def gen(*objs)
  Marshal.dump(objs, @tempfile)
end

#newObject



64
65
66
67
68
69
# File 'lib/tb/fileenumerator.rb', line 64

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