Class: CorrectHorseBatteryStaple::Writer::Json
- Inherits:
-
File
- Object
- CorrectHorseBatteryStaple::Writer
- Base
- File
- CorrectHorseBatteryStaple::Writer::Json
- Defined in:
- lib/correct_horse_battery_staple/writer/json.rb
Instance Attribute Summary
Attributes inherited from File
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(dest, options = {}) ⇒ Json
constructor
A new instance of Json.
- #write_corpus(corpus) ⇒ Object
Methods inherited from File
Methods inherited from Base
Methods included from Common
#array_sample, #logger, #random_in_range, #random_number, #set_sample
Methods inherited from CorrectHorseBatteryStaple::Writer
Constructor Details
#initialize(dest, options = {}) ⇒ Json
Returns a new instance of Json.
3 4 5 |
# File 'lib/correct_horse_battery_staple/writer/json.rb', line 3 def initialize(dest, ={}) super end |
Instance Method Details
#write_corpus(corpus) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/correct_horse_battery_staple/writer/json.rb', line 7 def write_corpus(corpus) print '{"stats": ' print corpus.stats.to_json print ', "corpus": [' i = 0 corpus.each do |word| puts "," if i >= 1 print(word.to_hash.to_json) i += 1 end puts "]\n}" end |