I have a command line application. the way to call it is :
ruby comb.rb --format json 'journals.csv' 'articles.csv' 'authors.json' > full_articles.json
Basically what it does is combining information from different files (the ones you pass as arguments). The format defines the format of the output.
An array of arrays arribes to the json presenter class (collection in the snipped).
I want to insert to a new file(the one I pass as the last argument) a json object (an array of objects).
This is part of the presenter class:
def call
collection.each do |line|
puts as_json line
end
end
private
def as_json line
{
"issn" => line[0],
"title" => line[1],
"doi" => line[2],
"author" => line[3],
"journal" => line[4]
}
end
The input I get to the full_articles.jsonfile is a set of objects but not encapsulated inside an array. Do you know how to solve this problem?
[{...}, {...}, {...}]?