Class: Xlsxtream::IO::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/xlsxtream/io/directory.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Directory

Returns a new instance of Directory.



6
7
8
# File 'lib/xlsxtream/io/directory.rb', line 6

def initialize(path)
  @path = Pathname(path)
end

Instance Method Details

#<<(data) ⇒ Object



10
11
12
# File 'lib/xlsxtream/io/directory.rb', line 10

def <<(data)
  @file << data
end

#add_file(path) ⇒ Object



14
15
16
17
18
19
# File 'lib/xlsxtream/io/directory.rb', line 14

def add_file(path)
  close
  file_path = @path + path
  file_path.parent.mkpath
  @file = file_path.open("wb")
end

#closeObject



21
22
23
# File 'lib/xlsxtream/io/directory.rb', line 21

def close
  @file.close if @file.respond_to? :close
end