Class: Unipept::XMLFormatter

Inherits:
Formatter show all
Defined in:
lib/formatters.rb

Instance Method Summary collapse

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 XML format.

Parameters:

  • data (Array)

    The data we wish to convert

  • Is (Boolean)

    this the first output batch?

Returns:

  • (String)

    The converted input data in the XML format



306
307
308
# File 'lib/formatters.rb', line 306

def convert(data, _first)
  data.map { |row| "<result>#{row.to_xml}</result>" }.join
end


295
296
297
# File 'lib/formatters.rb', line 295

def footer
  "</results>\n"
end

#header(_data, _fasta_mapper = nil) ⇒ Object



291
292
293
# File 'lib/formatters.rb', line 291

def header(_data, _fasta_mapper = nil)
  '<results>'
end

#typeString

Returns The type of the current formatter: xml.

Returns:

  • (String)

    The type of the current formatter: xml



287
288
289
# File 'lib/formatters.rb', line 287

def type
  'xml'
end