Class: CorrectHorseBatteryStaple::Writer
- Inherits:
-
Object
- Object
- CorrectHorseBatteryStaple::Writer
show all
- Defined in:
- lib/correct_horse_battery_staple/writer.rb
Direct Known Subclasses
Base
Defined Under Namespace
Classes: Base, Csv, File, Isam, Isamkd, Json, Marshal, Redis, Sqlite
Class Method Summary
collapse
Class Method Details
.make_writer(dest, fformat, options = {}) ⇒ Object
2
3
4
5
6
7
8
|
# File 'lib/correct_horse_battery_staple/writer.rb', line 2
def self.make_writer(dest, fformat, options = {})
fformat ||= CorrectHorseBatteryStaple::Corpus.format_for(dest)
raise ArgumentError, "Cannot determine file format for #{dest}" if !fformat || fformat.empty?
clazz = const_get(fformat.downcase.capitalize)
clazz.new(dest, options)
end
|
.write(corpus, dest, fformat, options = {}) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/correct_horse_battery_staple/writer.rb', line 10
def self.write(corpus, dest, fformat, options = {})
writer = self.make_writer(dest, fformat, options)
begin
writer.write_corpus(corpus)
ensure
writer && writer.close
end
end
|