Method: GPX::GPXFile#write

Defined in:
lib/gpx/gpx_file.rb

#write(filename, update_time = true) ⇒ Object

Serialize the current GPXFile to a gpx file named <filename>. If the file does not exist, it is created. If it does exist, it is overwritten.



213
214
215
216
217
218
# File 'lib/gpx/gpx_file.rb', line 213

def write(filename, update_time = true)
  @time = Time.now if @time.nil? || update_time
  @name ||= File.basename(filename)
  doc = generate_xml_doc
  File.open(filename, 'w+') { |f| f.write(doc.to_xml) }
end