324: def to_line(details)
325: unless record = record_type(details[:record_type])
326: raise ArgumentError, "Invalid record type %s" % details[:record_type].inspect
327: end
328:
329: if record.respond_to?(:pre_gen)
330: details = details.dup
331: record.send(:pre_gen, details)
332: end
333:
334: case record.type
335: when :text; return details[:line]
336: else
337: if record.respond_to?(:to_line)
338: return record.to_line(details)
339: end
340:
341: line = record.join(details)
342:
343: if regex = record.rts
344:
345: if regex == true
346: regex = /\s+$/
347: end
348: return line.sub(regex,'')
349: else
350: return line
351: end
352: end
353: end