Class: Codnar::Writer
- Inherits:
-
Object
- Object
- Codnar::Writer
- Defined in:
- lib/codnar/writer.rb
Overview
Write chunks into a disk file.
Class Method Summary collapse
-
.write(path, data) ⇒ Object
Write one chunk or an array of chunks to a disk file.
Instance Method Summary collapse
-
#<<(data) ⇒ Object
Add one chunk or an array of chunks to the disk file.
Class Method Details
.write(path, data) ⇒ Object
Write one chunk or an array of chunks to a disk file.
7 8 9 10 11 |
# File 'lib/codnar/writer.rb', line 7 def self.write(path, data) self.new(path) do |writer| writer << data end end |
Instance Method Details
#<<(data) ⇒ Object
Add one chunk or an array of chunks to the disk file.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/codnar/writer.rb', line 14 def <<(data) case data when Array @chunks += data when Hash @chunks << data else raise "Invalid data class: #{data.class}" end end |