Class: Unipept::JSONFormatter
Instance Method Summary collapse
-
#convert(data, first) ⇒ String
Converts the given input data to the JSON format.
- #footer ⇒ Object
- #header(_data, _fasta_mapper = nil) ⇒ Object
-
#type ⇒ String
The type of the current formatter: json.
Methods inherited from Formatter
available, default, #format, formatters, #group_by_first_key, hidden?, #integrate_fasta_headers, new_for_format, register
Instance Method Details
#convert(data, first) ⇒ String
Converts the given input data to the JSON format.
157 158 159 160 |
# File 'lib/formatters.rb', line 157 def convert(data, first) output = data.map(&:to_json).join(',') first ? output : ",#{output}" end |
#footer ⇒ Object
146 147 148 |
# File 'lib/formatters.rb', line 146 def "]\n" end |
#header(_data, _fasta_mapper = nil) ⇒ Object
142 143 144 |
# File 'lib/formatters.rb', line 142 def header(_data, _fasta_mapper = nil) '[' end |
#type ⇒ String
Returns The type of the current formatter: json.
138 139 140 |
# File 'lib/formatters.rb', line 138 def type 'json' end |