Class: Bparity::Corpus::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/bparity/corpus.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/bparity/corpus.rb', line 9

def path
  @path
end

Instance Method Details

#closeObject



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