class Quadtone::CGATS::Section
Attributes
data[RW]
data_fields[RW]
header[RW]
Public Class Methods
new()
click to toggle source
# File lib/quadtone/cgats.rb, line 93 def initialize @header = {} @data = [] @data_fields = [] end
Public Instance Methods
<<(set)
click to toggle source
# File lib/quadtone/cgats.rb, line 99 def <<(set) @data << set end
write(io)
click to toggle source
# File lib/quadtone/cgats.rb, line 103 def write(io) # header @header.each { |k, v| io.puts k.to_s + (v ? " \"#{v}\"" : '') } # data format io.puts io.puts "NUMBER_OF_FIELDS #{@data_fields.length}" io.puts 'BEGIN_DATA_FORMAT' io.puts @data_fields.join(' ') io.puts 'END_DATA_FORMAT' # data io.puts io.puts "NUMBER_OF_SETS #{@data.length}" io.puts 'BEGIN_DATA' @data.each do |set| fields = @data_fields.map do |f| case (d = set[f]) when Float '%.05f' % d when String '"' + d + '"' else d end end io.puts fields.join(' ') end io.puts 'END_DATA' nil end