Class: Bparity::Corpus::Writer
- Inherits:
-
Object
- Object
- Bparity::Corpus::Writer
- Defined in:
- lib/bparity/corpus.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(path) ⇒ Writer
constructor
A new instance of Writer.
- #write(record) ⇒ Object
Constructor Details
#initialize(path) ⇒ Writer
Returns a new instance of Writer.
11 12 13 14 15 |
# File 'lib/bparity/corpus.rb', line 11 def initialize(path) @path = path FileUtils.mkdir_p(File.dirname(path)) @io = File.open(path, "w") end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/bparity/corpus.rb', line 9 def path @path end |
Instance Method Details
#close ⇒ Object
22 |
# File 'lib/bparity/corpus.rb', line 22 def close = @io.close |
#write(record) ⇒ Object
17 18 19 20 |
# File 'lib/bparity/corpus.rb', line 17 def write(record) @io.puts(JSON.generate(record)) @io.flush end |